PHP Laravel PDOException General error referencing column and referenced column in a foreign key constraint are incompatible

If you're on Laravel 5.8 new migration changed to big increments, so for fixining refrencing error just change integer to bigInteger, for example:

$table->integer('user_id')->unsigned()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

Will changed to:

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

Either change original migration from

bigIncrements()

to just

increments();


Or In your foreign key column do

bigInteger()

instead of

integer()


In Laravel 6.0, migrations are as same as @Payam Khaninejad mentioned. i.e.

$table->bigInteger('user_id')->unsigned()->index();

I am updating that for Laravel 6.0 because, I was following an old tutorial that has shown the same error.