Skip to content
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

Products also need to destroy dependent models. #743

Merged
merged 1 commit into from
Jan 25, 2017

Conversation

nickcharlton
Copy link
Member

This is related to #739 and #738.

@danbee
Copy link
Contributor

danbee commented Jan 25, 2017

Is this actually desired though? In a normal online store you'd want historic orders to maintain a record of the products that were actually ordered.

@nickcharlton
Copy link
Member Author

In an actual store, no.

So we could either do this to avoid getting a 500 when someone tries deleting, adjust the demo data model to take that into account or have an error message. As it's just a demo, this is an easier way of solving that.

@danbee
Copy link
Contributor

danbee commented Jan 25, 2017

Given that this is a demo this is a reasonable approach. Although we could mark the products as deleted instead which would solve the line_item association problem in a way that would be more in line with how a real store would do it.

@nickcharlton
Copy link
Member Author

Yeah, I'm wondering now if we shouldn't use it being a demo as an excuse and instead do it properly.

@BenMorganIO
Copy link
Collaborator

BenMorganIO commented Jan 25, 2017

In theory, line items should be "destroyed" when orders are destroyed; although orders should never be destroyed (especially completed ones). Paranoia would be great for archiving the products.

But this is just a demo and I feel it'd be a tad bit too much. Users probably aren't expecting an actual online store. I'm 👍 for this. Another alternative could be to nullify the foreign key, rather than cascade.

@nickcharlton nickcharlton merged commit 16e7490 into master Jan 25, 2017
@nickcharlton nickcharlton deleted the nc-cascade-delete-products branch January 25, 2017 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants