Answers for "Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'user_id_fk' are incompatible."

SQL
0

SQLSTATE[HY000]: General error: 3780 Referencing column 'role_id' and referenced column 'id' in foreign key constraint 'user_role_id foreign' are incompatible.

As the name says the referenced foreign key and the id in the table are not of 
same type. 

Example : 

// user_id foreign key referenced table
$table->bigInteger('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');


// Then inside users table
$table->bigIncrements('id')->unsigned()->index();
Posted by: Guest on November-30-2020
0

referencing column and referenced column in foreign key constraint are incompatible.

Just throwing this into the mix of possible causes, I ran into this when the referencing table column had the same "type" but did not have the same signing.

In my case, the referenced table colum was TINYINT UNSIGNED and my referencing table column was TINYINT SIGNED. Aligning both columns solved the issue.
Posted by: Guest on March-20-2021

Code answers related to "Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'user_id_fk' are incompatible."

Code answers related to "SQL"

Browse Popular Code Answers by Language