Categories
Laravel Quick Fix

Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails

The full messy error message can look like this: PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails This can happen when, let’s say, you have related columns Posts and Comments and you want to delete post, assuming that related comments will be swept away […]