refs #6159 fixtrigger
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-09-06 13:59:28 +02:00
parent 05a73247a1
commit 04d04e6598
4 changed files with 22 additions and 52 deletions

View File

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

View File

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

View File

@ -1965,12 +1965,6 @@ INSERT INTO `vn`.`calendarType` (`id`, `description`, `hoursWeek`, `isPartial`)
VALUES VALUES
(1, 'General schedule', 40, 0); (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; DROP TEMPORARY TABLE IF EXISTS tmp.worker;
CREATE TEMPORARY TABLE tmp.worker CREATE TEMPORARY TABLE tmp.worker
(PRIMARY KEY (id)) (PRIMARY KEY (id))
@ -1994,9 +1988,6 @@ INSERT INTO `vn`.`business` (`id`, `workerFk`, `companyCodeFk`, `started`, `ende
DROP TEMPORARY TABLE IF EXISTS tmp.worker; DROP TEMPORARY TABLE IF EXISTS tmp.worker;
DELETE FROM `account`.`account`
WHERE id = 1105;
UPDATE `vn`.`business` UPDATE `vn`.`business`
SET `payedHolidays`= 8 SET `payedHolidays`= 8
WHERE `id`= 1106; WHERE `id`= 1106;

View File

@ -17,7 +17,7 @@ describe('Client setPassword', () => {
let error; let error;
try { try {
await models.Client.setPassword(1105, 't0pl3v3l.p455w0rd!'); await models.Client.setPassword(1101, 't0pl3v3l.p455w0rd!');
} catch (e) { } catch (e) {
error = e; error = e;
} }