Add ON DELETE CASCADE on child tables #511
Replies: 2 comments
-
I prefer to let my code manage all my persistence logic, otherwise you get tightly coupled to how your data is persisted. Things like foreign keys and not-nullable fields make it harder to generate interesting test data or do imports and other migrations. This leads to the bad habit of trusting persistence data in your code: "this column is INT NOT NULL so I don't need to check I know I'm not in the majority so I will let the team decide on this one: just my two cents. |
Beta Was this translation helpful? Give feedback.
-
We have already set |
Beta Was this translation helpful? Give feedback.
-
to remove a user, you need to delete all rows related to the user from other tables as the example shows below. Would it be a better idea to add the ON DELETE CASCADE feature to all child tables so you only have to delete the user from the users table?
Beta Was this translation helpful? Give feedback.
All reactions