G
G
GrimJack2017-08-21 14:12:51
PostgreSQL
GrimJack, 2017-08-21 14:12:51

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');
        });

Falling with an error
[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`))

As I understand it, it swears, such that the fields are not of the same type. But they are both unteger, what's the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2017-08-21
@GrimJack

$table->integer('linked_record_id')->unsiged();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question