laravelでテーブル 'チーム'と '競争'を作成しようとしていますが、migrateコマンドを実行すると次のようになります:errno:150 " "Laravel - 外部キー制約が正しく形成されていません
Schema::create('competitions', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('team_name');
$table->foreign('team_name')->references('name')->on('teams')->onDelete('cascade');
$table->timestamps();
});
Schema::create('teams', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('place');
$table->string('competition')->nullable();;
$table->foreign('competition')->references('name')->on('competitions')->onDelete('set null');
$table->timestamps();
});
いいえ、まだ同じエラーが機能しませんでした – jordibenck