Skip to content

Commit

Permalink
fix: define index prefix length for MySQL (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
iv-craig authored Sep 3, 2023
1 parent 4baa379 commit d3da820
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion database/migrations/2019_03_29_163611_add_webauthn.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use Illuminate\Database\ConnectionResolverInterface as Resolver;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Expand Down Expand Up @@ -29,7 +31,12 @@ public function up()
$table->timestamps();

$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->index('credentialId');

if (app(Resolver::class)->connection($this->getConnection()) instanceof MySqlConnection) {
$table->index([app('db')->raw('credentialId(255)')], 'credential_index');
} else {
$table->index('credentialId');
}
});
}

Expand Down

0 comments on commit d3da820

Please sign in to comment.