Laravel: указанный ключ был слишком длинным даже после изменения AppServiceProvider
После установки https://github.com/laravel-notification-channels/webpush я захотел перенести их таблицу:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePushSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('push_subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->string('endpoint', 500)->unique();
$table->string('public_key')->nullable();
$table->string('auth_token')->nullable();
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('push_subscriptions');
}
}
Но когда я хочу мигрировать, я получаю следующую ошибку:
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `push_subscriptions` add unique `push_subscriptions_endpoint_unique`(`endpoint`))
Но я уже изменил AppServiceProvider ранее к этому:
public function boot()
{
Schema::defaultStringLength(191);
}
Поэтому мне кажется, что это больше не должно давать мне ошибки, потому что я уже изменил AppServiceProvider. Я также пытался изменить endpoint
строковое значение до 250 вместо 500, но оно все равно не будет работать. Я что-то пропустил?
Обновить:
Я изменился
//config/database.php
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
в
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
в соответствии с этой проблемой на github: https://github.com/laravel/framework/issues/20012 но я все еще получаю то же