cascade in laravel migration 1

cascade in laravel migration


Here is what the above code is Doing:
1. We’re adding a new foreign key constraint to the answers table.
2. We’re naming the new foreign key constraint answers_user_id_foreign.
3. We’re referencing the user_id column in the answers table.
4. We’re referencing the id column in the users table.
5. We’re telling the database to delete any answers that belong to a user if that user is deleted.

Similar Posts