Chapters
00:00 - Gracefully Deleting A Not Null Foreign Key Relationship
00:56 - Creating An Example of our Use-Case
03:30 - Adding $extras to our DTOs as Meta
05:31 - Adding a Replacement Select to the Delete Confirmation Dialog
07:42 - Adding Form Data to the Delete Confirmation Dialog
09:07 - Computing the Replacement Options
09:44 - Adding a Difficulty Destroy Validator
10:46 - Passing Meta Data Into Our Validator
12:11 - Validating the Destroy Action
12:50 - Replacing the Difficulty Before Deleting It
14:42 - Adding Select Support to our FormInput Component
15:54 - Testing our Delete Replacement Flow
Join The Discussion! (2 Comments)
Please sign in or sign up for free to join in on the dicussion.
aaron-ford
Is AdonisJS set up to handle soft deletes? If you didn't want to replace the difficulty and maintain the original relationships? Or if you wanted to delete a course or organization for some reason, and not lose any records you might have to things like users grades?
Also, I feel like I've occasionally seen warnings in the code that I think are due to FormInput type group (remember me on the login page) not having a label or a v-model attribute. Should a group type have those attributes? Or should they be made optional in the FormInput's defined props?
Please sign in or sign up for free to reply
tomgobich
Hi Aaron! Unfortunately, not out of the box. Looks like there is a community package to add support for it, though. An alternative approach I've seen discussed is to have a
soft_deletes
table that contains a serialized version of the deleted row with additional columns specifying its original table & id. You'd then delete the record, serialize it, then add it to thesoft_deletes
table so that you can still grab it and restore it if needed. I've never attempted this approach, but it does sound interesting, so I thought I'd share. Not sure how this would handle foreign keys pointing to the deleted id though.Yes, sorry about that, those should be optional props!
Please sign in or sign up for free to reply