-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependent Destroy #14
Comments
I think |
Do you think there should ever be a reason to turn it off at the class level or via config/initializer? |
Definitely a breaking change. I've relied on orphaned transition records for deriving rough analytics / business intelligence (being able to see what happened historically even if you don't have the current parent record anymore). Not saying the non-destroy behavior has to be the default, but for my use case I would have been annoyed if they started being deleted along with the parent record. |
@smudge Good point. What code are you using to avoid the foreign key violation? |
@victornamuso In my case I just removed the foreign key constraint (in postgres) and used a vanilla index instead. (Because I wanted to preserve the deleted record's ID.) But you could also use |
@smudge it seems like it would be cleaner to change the default implementation to be all inclusive so nothing out of the box would be needed post generator. Whether that is redefining the default migration, doing dependent: :nullify or dependent: :destroy, then make it configurable at the app and class level. Seems like handling it the way you do it would be the best, as it has the least amount of destruction. There's always just leaving it the way it is and having the generator read the configuration to determine the behavior as this would ensure maximum backward compatibility. |
I'm not of the mindset that backward compatibility makes sense here. Having an FK of I think We can increment the version appropriately and list it as a breaking change. @victornamuso are you using this with Rails 5? |
Yeah I don't want to prescribe a default -- to support my use case I think it would be fine to make the breaking change, increment the version accordingly, and provide a way to change the default behavior to allow for orphaned log entries. |
@rosskevin Not yet, but I'll be making that move over early next year. |
+dependent destroy. super important. or make it as an option, so we can select our own thing.
|
Hey folks, did we ever come to an agreement on this? Found myself bumping into it today. I'm currently redefining the has_many association myself in the model to add dependent destroy. |
@SirRawlins Read back through it, and I don't think that we did. Any input on how we want to do this? |
I reached agreement with myself on what should be the plan! Absent any dissent, this is the plan:
and
and
|
Thanks @rosskevin. Unless someone else wants it, I can get around to putting in a PR sometime this month. |
Thanks @victornamuso |
Is there any news on this issue ? I remove the |
@btrd, totally slipped off my radar sorry! I put a reminder on my calendar to work on this next week. |
Awesone, thanks ! I can try to make a PR if you don't have the time to work on it. |
I noticed there is an issue when destroying the parent record which throws a foreign key violation on the transition record. I got around it with a
before_destroy
. Would be nice to have one of the following:OR
Would like to hear your thoughts on this. If you'd like this done, I'd be happy to code it and issue a PR.
The text was updated successfully, but these errors were encountered: