私はLaravelsのデフォルトの移行を使用して通知テーブルを作成しています。Laravel通知テーブルを作成するときに「指定されたキーが長すぎます」
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('type');
$table->morphs('notifiable');
$table->text('data');
$table->timestamp('read_at')->nullable();
$table->timestamps();
});
}
しかし、それを使用しようとすると、私はエラーを取得する:
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `notifications` add index `n
otifications_notifiable_id_notifiable_type_index`(`notifiable_id`, `notifiable_type`))
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
更新
私はnotifiable_indexにインデックス列の名前を変更しましたが、長さについて、それはまだ不満インデックスキーの
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `notifications` add index `n
otifiable_index`(`notifiable_id`, `notifiable_type`))
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
「通知可能な」列の照合とは何ですか? – user3158900
これを解決しましたか? –
@PhilippSanderは短いキーを作成する別の方法を使用しなければなりませんでした。 – naneri