Explain why triggers aren't working after adding the following migration #33691
Labels
area-migrations
closed-no-further-action
The issue is closed and no further action is planned.
customer-reported
Issue Description
After applying the
Initialize_DB
migration containing severalCREATE TRIGGER
statements for theCartItems
table, it appears that the triggers are not functioning as expected. Specifically, the triggers designed to manage the book quantity based onCartItems
insertions, deletions, and updates are not modifying theBooks
table as intended.Migration Context
The
Initialize_DB
migration creates several tables, includingCartItems
,Books
, and related tables likeAuthors
,Genres
,Images
,Languages
, andUsers
. It also adds the following triggers:trg_after_insert_decrease_book_quantity
: Before inserting intoCartItems
, it decreases the quantity of the corresponding book.trg_after_delete_increase_book_quantity
: Before deleting fromCartItems
, it increases the quantity of the corresponding book.trg_after_update_adjust_book_quantity
: Before updating inCartItems
, it adjusts the quantity of the corresponding book.The migration also contains the following code snippets:
Despite these triggers being created without errors, their intended functionality isn't being observed.
Expected Behavior
The triggers should adjust the
Books
table'sQuantity
field based on operations performed on theCartItems
table. When adding items to a cart, the quantity should decrease. Similarly, when removing or updating cart items, the book quantity should adjust accordingly.The text was updated successfully, but these errors were encountered: