diff --git a/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql b/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql new file mode 100644 index 000000000..824f0982b --- /dev/null +++ b/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerManaExcluded_beforeInsert` + BEFORE INSERT ON `workerManaExcluded` + FOR EACH ROW +BEGIN + DELETE FROM workerMana + WHERE workerFk = NEW.workerFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql b/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql new file mode 100644 index 000000000..83d73e131 --- /dev/null +++ b/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerManaExcluded_beforeUpdate` + BEFORE UPDATE ON `workerManaExcluded` + FOR EACH ROW +BEGIN + DELETE FROM workerMana + WHERE workerFk = NEW.workerFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerMana_beforeInsert.sql b/db/routines/vn/triggers/workerMana_beforeInsert.sql new file mode 100644 index 000000000..2d27004e3 --- /dev/null +++ b/db/routines/vn/triggers/workerMana_beforeInsert.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerMana_beforeInsert` + BEFORE INSERT ON `workerMana` + FOR EACH ROW +BEGIN + IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN + CALL util.throw('Worker is excluded from mana'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerMana_beforeUpdate.sql b/db/routines/vn/triggers/workerMana_beforeUpdate.sql new file mode 100644 index 000000000..6916733cb --- /dev/null +++ b/db/routines/vn/triggers/workerMana_beforeUpdate.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerMana_beforeUpdate` + BEFORE UPDATE ON `workerMana` + FOR EACH ROW +BEGIN + IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN + CALL util.throw('Worker is excluded from mana'); + END IF; +END$$ +DELIMITER ; diff --git a/db/versions/11396-blueErica/00-firstScript.sql b/db/versions/11396-blueErica/00-firstScript.sql new file mode 100644 index 000000000..b21965fe8 --- /dev/null +++ b/db/versions/11396-blueErica/00-firstScript.sql @@ -0,0 +1,5 @@ +DELETE FROM vn.workerMana + WHERE workerFk IN ( + SELECT workerFk + FROM vn.workerManaExcluded + );