nafiesl/SimpleCrudGenerator

[BUG] Foreign key constraint error after artisan migrate on Laravel 5.8

Closed this issue · 2 comments

A facebook friend named Adhik Mulat, inform that he got following error (foreign key constraint) when on artisan migrate command after generate a model CRUD.

simple-crud-error-laravel-5 8

This happened because in laravel 5.8 the default users table migration uses bigIncrement data type on id column. But in generated migration file (like image below) the foreign user_id colum still using integer (not big integer).

Laravel 5.8 users table migration file

photo_2019-03-09_15-06-08

Generated migration file

photo_2019-03-09_15-05-52

To solve this problem, we need to change the migration file stub.

$table->unsignedInteger('creator_id');

This line need to changed into

$table->unsignedBigInteger('creator_id'); 

Resolved with this commit e445fc8.