I can't roll back migrations because a foreign id constraint fails despite using nullable()
for the respective nullOnDelete()
/onDelete('set null')
columns schema.
I have the following line in notes table schema:
$table->foreignId('administrator_id')
->nullable()
->constrained()
->cascadeOnUpdate()
->onDelete('set null');
Migrations do run correctly, however, if I try to migrate:refresh
it always fails with:
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (Connection: mysql, SQL: drop table if exists
administrators
)
I've tried nullOnDelete()
instead of onDelete('set null')
, same issue.
The Laravel framework version is 10.10
, and the database I'm using is MariaDB 11.0.2
.
Note that I don't want to cascade my entries on delete.