DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeUpdate`
	BEFORE UPDATE ON `roadmapStop`
	FOR EACH ROW
BEGIN
	SET NEW.editorFk = account.myUser_getId();

	IF NOT (NEW.description <=> OLD.description) THEN
		SET NEW.description = UCASE(NEW.description);
	END IF;

	IF NOT (NEW.roadmapFk <=> OLD.roadmapFk) OR NOT (NEW.eta <=> OLD.eta) THEN

		IF NEW.eta < (SELECT etd FROM roadmap WHERE id = NEW.roadmapFk) THEN
			CALL util.throw('Departure time can not be after arrival time');
		END IF;
	END IF;
END$$
DELIMITER ;