Skip to content
Advertisement

Tag: foreign-keys

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row in Laravel9

I have an integrity constraint violation when I run the php artisan db:seed command in Laravel 9. Error PDOException::(“SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (hunger-db.restaurants, CONSTRAINT restaurants_user_id_foreign FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE)”) setup_users_table setum_restaurants_table User Model Restaurant Model Answer I see some things to change

Advertisement