salix/db/changes/10120-december/00-userAfterUpdate.sql

19 lines
536 B
MySQL
Raw Normal View History

2019-11-26 13:15:43 +00:00
DROP TRIGGER IF EXISTS `account`.`user_afterUpdate`;
DELIMITER $$
CREATE DEFINER=`root`@`%` TRIGGER `account`.`user_afterUpdate`
AFTER UPDATE ON `user`
FOR EACH ROW
BEGIN
IF !(NEW.`role` <=> OLD.`role`)
THEN
INSERT INTO vn.mail SET
`sender` = 'jgallego@verdnatura.es',
`replyTo` = 'jgallego@verdnatura.es',
`subject` = 'Rol modificado',
`body` = CONCAT(myUserGetName(), ' ha modificado el rol del usuario ',
NEW.`name`, ' de ', OLD.role, ' a ', NEW.role);
END IF;
END$$
DELIMITER ;