Answer the question
In order to leave comments, you need to log in
Why isn't the connection made on itself?
Hello.
Created a migration
Schema::create('records', function (Blueprint $table) {
$table->increments('record_id');
$table->integer('linked_record_id')->default('0');
$table->integer('company_id');
$table->integer('form_id')->default('0');
$table->uuid('uuid');
$table->timestamps();
$table->foreign('linked_record_id')->references('record_id')->on('records');
$table->foreign('company_id')->references('company_id')->on('companies');
$table->foreign('form_id')->references('form_id')->on('forms');
});
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `records ` add constraint `records_linked_record_id_foreign` foreign key (`linked_record_id`) references `records` (`record_id`))
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