From 04d04e6598a37c424400c9855ad55c252e5cf9de Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 6 Sep 2023 13:59:28 +0200 Subject: [PATCH] refs #6159 fixtrigger --- .../233601/00-updateAfterBusinnesInsert.sql | 42 ------------------- .../233801/00-updateAfterBusinnesInsert.sql | 21 ++++++++++ db/dump/fixtures.sql | 9 ---- .../methods/client/specs/setPassword.spec.js | 2 +- 4 files changed, 22 insertions(+), 52 deletions(-) delete mode 100644 db/changes/233601/00-updateAfterBusinnesInsert.sql create mode 100644 db/changes/233801/00-updateAfterBusinnesInsert.sql diff --git a/db/changes/233601/00-updateAfterBusinnesInsert.sql b/db/changes/233601/00-updateAfterBusinnesInsert.sql deleted file mode 100644 index f2b5dc753..000000000 --- a/db/changes/233601/00-updateAfterBusinnesInsert.sql +++ /dev/null @@ -1,42 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_afterInsert` - AFTER INSERT ON `business` - FOR EACH ROW -BEGIN - CALL worker_updateBusiness(NEW.workerFk); - - IF ( - SELECT NOT active - FROM account.user - WHERE id = NEW.workerFk - ) THEN - UPDATE account.user - SET active = TRUE - WHERE id = NEW.workerFk; - END IF; - - IF ( - SELECT NOT COUNT(aa.id) - FROM account.mailAliasAccount aa - JOIN account.mailAlias ma ON ma.id = aa.mailAlias - WHERE aa.account = NEW.workerFk - AND ma.alias = 'general' - ) THEN - INSERT INTO account.mailAliasAccount (mailAlias, account) - SELECT id, NEW.workerFk - FROM account.mailAlias - WHERE alias = 'general'; - END IF; - - IF ( - SELECT NOT COUNT(account) - FROM account.mailForward - WHERE account = NEW.workerFk - ) THEN - INSERT INTO account.mailForward (account, forwardTo) - SELECT NEW.workerFk, email - FROM account.user - WHERE id = NEW.workerFk; - END IF; -END$$ -DELIMITER ; diff --git a/db/changes/233801/00-updateAfterBusinnesInsert.sql b/db/changes/233801/00-updateAfterBusinnesInsert.sql new file mode 100644 index 000000000..82c71507c --- /dev/null +++ b/db/changes/233801/00-updateAfterBusinnesInsert.sql @@ -0,0 +1,21 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`business_afterInsert` + AFTER INSERT ON `business` + FOR EACH ROW +BEGIN + CALL worker_updateBusiness(NEW.workerFk); + UPDATE account.user + SET active = TRUE + WHERE id = NEW.workerFk; + + INSERT IGNORE INTO account.mailAliasAccount (mailAlias, account) + SELECT id, NEW.workerFk + FROM account.mailAlias + WHERE alias = 'general'; + + INSERT IGNORE INTO account.mailForward (account, forwardTo) + SELECT NEW.workerFk, email + FROM account.user + WHERE id = NEW.workerFk; +END$$ +DELIMITER ; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5ac355ea4..68922d176 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1965,12 +1965,6 @@ INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`) VALUES (1, 'General schedule', 40, 0); -INSERT INTO `account`.`account`(id) - SELECT u.id - FROM account.user u - LEFT JOIN account.account a ON a.id = u.id - WHERE a.id IS NULL; - DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) @@ -1994,9 +1988,6 @@ INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ende DROP TEMPORARY TABLE IF EXISTS tmp.worker; -DELETE FROM `account`.`account` - WHERE id = 1105; - UPDATE `vn`.`business` SET `payedHolidays`= 8 WHERE `id`= 1106; diff --git a/modules/client/back/methods/client/specs/setPassword.spec.js b/modules/client/back/methods/client/specs/setPassword.spec.js index 841f173bd..590172a02 100644 --- a/modules/client/back/methods/client/specs/setPassword.spec.js +++ b/modules/client/back/methods/client/specs/setPassword.spec.js @@ -17,7 +17,7 @@ describe('Client setPassword', () => { let error; try { - await models.Client.setPassword(1105, 't0pl3v3l.p455w0rd!'); + await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!'); } catch (e) { error = e; }