I have user_id fk column in my table
$table->foreign(\'user_id\')->references(\'id\')->on(\'users\');
I should add on cascade
$table->integer('user_id')->unsigned();
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
I am assuming you used Illuminate\Database\Schema\Blueprint::primary()
to create users.id
. If that is the case, then users.id
will be unsigned. Therefore your foreign key column user_id
must also be unsigned.