Answer the question
In order to leave comments, you need to log in
Why is the key not being added?
Migration
$table->bigIncrements('id');
$table->integer('user_id')->unsigned();
$table->integer('project_id')->unsigned();
$table->integer('referral_id')->unsigned();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('CASCADE');
$table->foreign('project_id')->references('id')->on('projects')->onDelete('CASCADE');
$table->foreign('referral_id')->references('id')->on('referrals')->onDelete('CASCADE');
Schema::create('referrals', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 100);
});
General error: 1215 Cannot add foreign key constraint (SQL: alter table `project_referrals` add constraint `project_referrals_referral_id_foreign` foreign key (`referral_id`) references `referrals` (`id`) on delete CASCADE)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question