Skip to content
Advertisement

Cannot add or update a child row: a foreign key constraint fails – Laravel 7

I’m trying to add a relationship 1:1 between my Visitor & Contact

JavaScript

When run

JavaScript

I kept getting

JavaScript

enter image description here

Advertisement

Answer

In the latest versions of laravel the primary key is biginteger. so you might have to change this

$table->integer(‘visitor_id’)->unsigned();

with this

$table->bigInteger(‘visitor_id’)->unsigned();

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement