refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale #3057

Merged
guillermo merged 9 commits from 6824-itemShelvingSaleNoDelete into dev 2024-10-07 05:50:49 +00:00
2 changed files with 13 additions and 22 deletions
Showing only changes of commit 7b4d15cb23 - Show all commits

View File

@ -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,
guillermo marked this conversation as resolved Outdated

itemShelvingSale esta es la part que no cal fer, sino canviar en itemShelvingSale a un Fk restrict

itemShelvingSale esta es la part que no cal fer, sino canviar en itemShelvingSale a un Fk restrict
itemFk)
VALUES( OLD.id,
account.myUser_getId(),
'ELIMINADO',
OLD.shelvingFk,
OLD.itemFk)$$
DELIMITER ;

View File

@ -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;