refactor: refs #8613 add fk to claimEnd.claimDestinationFk #3479

Merged
ivanm merged 7 commits from 8613-addFkClaimDestinationFk into dev 2025-02-24 15:09:26 +00:00
3 changed files with 16 additions and 0 deletions
Showing only changes of commit 723eaed19b - Show all commits

View File

@ -4,5 +4,6 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`claimEnd_beforeInsert`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
SET NEW.claimDestinationFk = 1;
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
UPDATE vn.claimEnd ce
JOIN(
SELECT id
FROM vn.claimEnd
WHERE claimDestinationFk NOT IN
(SELECT id FROM vn.claimDestination WHERE id IS NOT NULL)
) s ON ce.id = s.id
SET ce.claimDestinationFk = 1;

View File

@ -0,0 +1,7 @@
ALTER TABLE vn.claimEnd
MODIFY COLUMN claimDestinationFk tinyint(3) unsigned NOT NULL,
ADD CONSTRAINT fk_claimEnd_claimDestination
FOREIGN KEY (claimDestinationFk)
REFERENCES claimDestination(id)
ON UPDATE CASCADE
ON DELETE CASCADE;
ivanm marked this conversation as resolved Outdated

ací en delete restrict, perque si algu tira a borrar un tipo de claim destination, no volem que borre en cascada totes les claimEnd que hi haja.

ací en delete restrict, perque si algu tira a borrar un tipo de claim destination, no volem que borre en cascada totes les claimEnd que hi haja.