From 052630d268139c62573f0e5430fcc0c54277fade Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 22 Jan 2025 12:40:58 +0100 Subject: [PATCH] feat: refs #8227 Roadmap changes --- db/routines/vn/triggers/roadmapStop_beforeInsert.sql | 5 +++++ db/routines/vn/triggers/roadmapStop_beforeUpdate.sql | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/db/routines/vn/triggers/roadmapStop_beforeInsert.sql b/db/routines/vn/triggers/roadmapStop_beforeInsert.sql index b87a52bdc..9ec8b72cf 100644 --- a/db/routines/vn/triggers/roadmapStop_beforeInsert.sql +++ b/db/routines/vn/triggers/roadmapStop_beforeInsert.sql @@ -5,5 +5,10 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeInser BEGIN SET NEW.editorFk = account.myUser_getId(); SET NEW.description = UCASE(NEW.description); + IF NEW.roadmapFk IS NOT NULL 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 ; diff --git a/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql b/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql index ec4dbe5ba..cff48846a 100644 --- a/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql +++ b/db/routines/vn/triggers/roadmapStop_beforeUpdate.sql @@ -5,5 +5,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeUpdat BEGIN SET NEW.editorFk = account.myUser_getId(); SET NEW.description = UCASE(NEW.description); + IF (NOT (NEW.roadmapFk <=> OLD.roadmapFk) AND NEW.roadmapFk IS NOT NULL) + OR (NOT (NEW.eta <=> OLD.eta) AND NEW.eta IS NOT NULL) 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 ;