Merge pull request 'refs #7651 Add editorFk and triggers' (!2661) from 7651-Add_editorFk_mailAliasAccount into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #2661
Reviewed-by: Guillermo Bonet <guillermo@verdnatura.es>
This commit is contained in:
Ivan Mas 2024-07-02 10:39:54 +00:00
commit 4ad6c440e0
4 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_afterDelete`
AFTER DELETE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
INSERT INTO userLog
SET `action` = 'delete',
`changedModel` = 'MailAliasAccount',
`changedModelId` = OLD.id,
`userFk` = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeInsert`
BEFORE INSERT ON `mailAliasAccount`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `account`.`mailAliasAccount_beforeUpdate`
BEFORE UPDATE ON `mailAliasAccount`
FOR EACH ROW
BEGIN
SET NEW.editorFk = account.myUser_getId();
END$$
DELIMITER ;

View File

@ -0,0 +1,4 @@
ALTER TABLE account.mailAliasAccount
ADD editorFk INT(10) UNSIGNED DEFAULT NULL,
ADD CONSTRAINT mailAliasAccount_editorFk FOREIGN KEY (editorFk)
REFERENCES account.`user`(id);