From 7b4d15cb23592446f9a1f2ffda92b822b64286d8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 07:30:36 +0200 Subject: [PATCH] refactor: refs #6824 Requested changes --- .../vn/triggers/itemShelving_beforeDelete.sql | 32 ++++++------------- .../11283-redAspidistra/00-firstScript.sql | 3 ++ 2 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 db/versions/11283-redAspidistra/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index dbfb63849..89737a841 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -2,26 +2,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW -BEGIN - DECLARE vItemShelvingSaleExists BOOL; - - SELECT COUNT(*) INTO vItemShelvingSaleExists - FROM itemShelvingSale - WHERE itemShelvingFk = OLD.id; - - IF vItemShelvingSaleExists THEN - CALL util.throw('Cannot delete item shelving with item shelving sale'); - END IF; - - INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk); -END$$ +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + shelvingFk, + itemFk) + VALUES( OLD.id, + account.myUser_getId(), + 'ELIMINADO', + OLD.shelvingFk, + OLD.itemFk)$$ DELIMITER ; diff --git a/db/versions/11283-redAspidistra/00-firstScript.sql b/db/versions/11283-redAspidistra/00-firstScript.sql new file mode 100644 index 000000000..a88091297 --- /dev/null +++ b/db/versions/11283-redAspidistra/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 + FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE RESTRICT ON UPDATE CASCADE;