refs #6159 fixBusinessAfterInsert
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2023-08-25 07:36:52 +02:00
parent 671e34da9a
commit 4ae06d4b6b
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,42 @@
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

@ -1965,6 +1965,11 @@ 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