Adds cascading delete when you delete an order, so that product_orders rows associated with the order are also deleted. Also added minor JavaScript styling changes to the OrdersModel.
Related Ticket(s)
Completes Issue #110 (Add Cascading Delete to Order Table/ Product_Order Join Table)
Problem to Solve
Product_orders entries were not being deleted when an order was deleted. When an order is deleted, the product_order entries associated with it should be deleted too.
Proposed Changes
Add ON DELETE CASCADE to Product_Orders table on the foreign_key order_id.
Expected Behavior
When you delete an order, all product_orders associated with it should be deleted too.
Steps to Test Solution
run npm run db:generate
run npm start
In your browser, go to http://localhost:8080/api/v1/orders/<An Order's ID with Products>
If that order does not have any products on it, find one that does.
In your database browser, run SELECT * FROM "Product_Orders" WHERE order_id = <An Order's ID with Products>;
A list of products should appear.
In Postman, run DELETE http://localhost:8080/api/v1/orders/<An Order's ID with Products>
In your database browser, run SELECT * FROM "Product_Orders" WHERE order_id = <An Order's ID with Products>;
Description
Adds cascading delete when you delete an order, so that product_orders rows associated with the order are also deleted. Also added minor JavaScript styling changes to the OrdersModel.
Related Ticket(s)
Completes Issue #110 (Add Cascading Delete to Order Table/ Product_Order Join Table)
Problem to Solve
Product_orders entries were not being deleted when an order was deleted. When an order is deleted, the product_order entries associated with it should be deleted too.
Proposed Changes
Add ON DELETE CASCADE to Product_Orders table on the foreign_key order_id.
Expected Behavior
When you delete an order, all product_orders associated with it should be deleted too.
Steps to Test Solution
npm run db:generate
npm start
http://localhost:8080/api/v1/orders/<An Order's ID with Products>
SELECT * FROM "Product_Orders" WHERE order_id = <An Order's ID with Products>;
DELETE http://localhost:8080/api/v1/orders/<An Order's ID with Products>
SELECT * FROM "Product_Orders" WHERE order_id = <An Order's ID with Products>;