DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN IF !(NEW.id <=> OLD.id) OR !(NEW.warehouseFk <=> OLD.warehouseFk) OR !(NEW.shipped <=> OLD.shipped) THEN CALL stock.log_add('ticket', NEW.id, OLD.id); END IF; IF !(NEW.clientFk <=> OLD.clientFk) OR !(NEW.addressFk <=> OLD.addressFk) OR !(NEW.companyFk <=> OLD.companyFk) THEN CALL ticket_requestRecalc(NEW.id); END IF; IF NEW.routeFk <> OLD.routeFk THEN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; END$$ DELIMITER ;