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 ;