From 9d7184ed7bc66f4a3a2a5a3e32076446f155edab Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 9 May 2024 12:35:26 +0200 Subject: [PATCH] refs #6965 Add Fk vehicleFk firstEditorFk --- db/versions/11040-grayMonstera/00-firstScript.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 db/versions/11040-grayMonstera/00-firstScript.sql diff --git a/db/versions/11040-grayMonstera/00-firstScript.sql b/db/versions/11040-grayMonstera/00-firstScript.sql new file mode 100644 index 000000000..0f20e771b --- /dev/null +++ b/db/versions/11040-grayMonstera/00-firstScript.sql @@ -0,0 +1,13 @@ +UPDATE vn.route + SET vehicleFk = NULL + WHERE vehicleFk NOT IN (SELECT id FROM vn.vehicle); + +ALTER TABLE vn.route +ADD CONSTRAINT route_vehicleFk FOREIGN KEY (vehicleFk) REFERENCES vn.vehicle(id); + +UPDATE vn.route + SET firstEditorFk = NULL + WHERE firstEditorFk NOT IN (SELECT id FROM vn.worker); + +ALTER TABLE vn.route +ADD CONSTRAINT route_firstEditorFk FOREIGN KEY (firstEditorFk) REFERENCES vn.worker(id);