DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
	BEFORE UPDATE ON `roadmap`
	FOR EACH ROW
BEGIN
	SET NEW.editorFk = account.myUser_getId();
	IF NEW.etd > NEW.eta THEN
		CALL util.throw('Departure time can not be after arrival time');
	END IF;

	IF NEW.tractorPlate IS NOT NULL THEN
		CALL vehicle_checkNumberPlate(NEW.tractorPlate, NULL);
	END IF;
	IF NEW.trailerPlate IS NOT NULL THEN
		CALL vehicle_checkNumberPlate(NEW.trailerPlate, NULL);
	END IF;
END$$
DELIMITER ;