stockpile-co / api

The API for Stockpile, an app that manages stuff for organizations.
0 stars 1 forks source link

Fix deletion of entities that are related to other entities #298

Closed emroussel closed 7 years ago

emroussel commented 7 years ago

When trying to delete a brand that is associated with one or multiple models, the api returns a 500. The same happens when trying to delete a brand, model or category associated to an item.

Instead, it should delete all related entities.

AdamVig commented 7 years ago

I fixed this specific issue by changing the "On Delete" on the Model -> Brand relation to CASCADE, so when a brand is deleted, all related models are also deleted.

However, when a user attempts to delete a brand/model that some items are assigned to, a 500 Internal Server Error will be returned and the brand/model will not be deleted.