LARAVEL 8: General error: 1005 occured while running migration with foreign key

By default Laravel 8 uses unsignedBigInteger as foreign key :

$table->bigInteger('user_id')->unsigned();
$table->foreign('user_id')->references('id')->on('users');

Alternative : Laravel provides additional, terser methods that use convention to provide a better developer experience. The example above could be written like so :

$table->foreignId('user_id')->constrained();

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top