foreign key constraint is incorrectly formed laravel

Posted by w3diy - 5 months ago

foreign key constraint is incorrectly formed laravel :

When creating a new table in Laravel. A migration will be generated like:

$table->bigIncrements('id');

Instead of (in older Laravel versions):

$table->increments('id');

Just add ->unsigned()->index() at the end of the foreign key and it will work.