MT
Size: a a a
MT
R
MT
MT
MT
A
A
A
DP
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `attempts` add constraint `attempts_test_id_foreign` foreign key (`test_id`) references `tests` (`id`))
DP
Schema::table('attempts', function($table) {
$table->foreign('test_id')->references('id')->on('tests');
$table->foreign('user_id')->references('id')->on('users');
});
A
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `attempts` add constraint `attempts_test_id_foreign` foreign key (`test_id`) references `tests` (`id`))
R
A
A
DP
A
Schema::table('attempts', function($table) {
$table->foreign('test_id')->references('id')->on('tests');
$table->foreign('user_id')->references('id')->on('users');
});
d.
DP
Schema::create('attempts', function (Blueprint $table) {
$table->id();
$table->timestamps();
...
$table->integer('user_id')->unsigned()->nullable();
$table->integer('test_id')->unsigned()->nullable();
});
d.
Schema::create('attempts', function (Blueprint $table) {
$table->id();
$table->timestamps();
...
$table->integer('user_id')->unsigned()->nullable();
$table->integer('test_id')->unsigned()->nullable();
});
d.