From b4e8fa28b5609e688cda4e6c4610136e803d760a Mon Sep 17 00:00:00 2001 From: pivovarvalera Date: Sat, 31 Jan 2026 18:02:13 +0300 Subject: [PATCH 1/4] DB, route_point_create | added table for manual route construction --- sql/result/route_point_create.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sql/result/route_point_create.sql diff --git a/sql/result/route_point_create.sql b/sql/result/route_point_create.sql new file mode 100644 index 0000000..480bdac --- /dev/null +++ b/sql/result/route_point_create.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS route_point; + +CREATE TABLE IF NOT EXISTS route_point ( + id SERIAL PRIMARY KEY, -- ID of the route point + pol_id INT NOT NULL, -- ID of the POL (Point Of Loading) + pod_id INT NOT NULL, -- ID of the POD (Point Of Discharge) + latitude FLOAT NOT NULL, -- Value of latitude + latitude FLOAT NOT NULL, -- Value of latitude + point_order INT NOT NULL, -- Order of route point + CONSTRAINT route_point_pol_fk FOREIGN KEY (pol_id) REFERENCES waypoint (id), + CONSTRAINT route_point_pod_fk FOREIGN KEY (pod_id) REFERENCES waypoint (id), + CONSTRAINT unique_route_order UNIQUE (pol_id, pod_id, point_order) +); \ No newline at end of file From b0d02abf821f1b827a24851bf96be39e01a9e11e Mon Sep 17 00:00:00 2001 From: pivovarvalera Date: Mon, 2 Feb 2026 16:06:38 +0300 Subject: [PATCH 2/4] DB, route_point_create | corrected pk, file moved to sql/voyage --- sql/{result => voyage}/route_point_create.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename sql/{result => voyage}/route_point_create.sql (83%) diff --git a/sql/result/route_point_create.sql b/sql/voyage/route_point_create.sql similarity index 83% rename from sql/result/route_point_create.sql rename to sql/voyage/route_point_create.sql index 480bdac..58d63bf 100644 --- a/sql/result/route_point_create.sql +++ b/sql/voyage/route_point_create.sql @@ -1,12 +1,13 @@ DROP TABLE IF EXISTS route_point; CREATE TABLE IF NOT EXISTS route_point ( - id SERIAL PRIMARY KEY, -- ID of the route point + id INT GENERATED ALWAYS AS IDENTITY, -- ID of the route point pol_id INT NOT NULL, -- ID of the POL (Point Of Loading) pod_id INT NOT NULL, -- ID of the POD (Point Of Discharge) latitude FLOAT NOT NULL, -- Value of latitude latitude FLOAT NOT NULL, -- Value of latitude point_order INT NOT NULL, -- Order of route point + CONSTRAINT route_point_pk PRIMARY KEY (id), CONSTRAINT route_point_pol_fk FOREIGN KEY (pol_id) REFERENCES waypoint (id), CONSTRAINT route_point_pod_fk FOREIGN KEY (pod_id) REFERENCES waypoint (id), CONSTRAINT unique_route_order UNIQUE (pol_id, pod_id, point_order) From 3b4be6d996981929ff62f76efaf91656ed8060fe Mon Sep 17 00:00:00 2001 From: pivovarvalera Date: Mon, 2 Feb 2026 18:32:13 +0300 Subject: [PATCH 3/4] DB, route_point_create | renamed parameters in table, added table to initialization file --- sql/init.sql | 3 +++ sql/voyage/route_point_create.sql | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/init.sql b/sql/init.sql index 6fafa4e..7470e2e 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -200,3 +200,6 @@ DROP TABLE IF EXISTS ship_geometry, ship_parameters, ship CASCADE; -- -- Initial ports data (moved to the bottom because after updating file something gone wrong) \i ./sql/voyage/port_create.sql +-- +-- Initial route points data +\i ./sql/voyage/route_point_create.sql diff --git a/sql/voyage/route_point_create.sql b/sql/voyage/route_point_create.sql index 58d63bf..22e5396 100644 --- a/sql/voyage/route_point_create.sql +++ b/sql/voyage/route_point_create.sql @@ -5,8 +5,8 @@ CREATE TABLE IF NOT EXISTS route_point ( pol_id INT NOT NULL, -- ID of the POL (Point Of Loading) pod_id INT NOT NULL, -- ID of the POD (Point Of Discharge) latitude FLOAT NOT NULL, -- Value of latitude - latitude FLOAT NOT NULL, -- Value of latitude - point_order INT NOT NULL, -- Order of route point + longitude FLOAT NOT NULL, -- Value of latitude + order INT NOT NULL, -- Order of route point CONSTRAINT route_point_pk PRIMARY KEY (id), CONSTRAINT route_point_pol_fk FOREIGN KEY (pol_id) REFERENCES waypoint (id), CONSTRAINT route_point_pod_fk FOREIGN KEY (pod_id) REFERENCES waypoint (id), From 0e1ac5b2ba4622cb31177808ec115e4ae76c83e7 Mon Sep 17 00:00:00 2001 From: pivovarvalera Date: Mon, 2 Feb 2026 18:34:07 +0300 Subject: [PATCH 4/4] DB, route_point_create | fixes --- sql/voyage/route_point_create.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/voyage/route_point_create.sql b/sql/voyage/route_point_create.sql index 22e5396..c3affe5 100644 --- a/sql/voyage/route_point_create.sql +++ b/sql/voyage/route_point_create.sql @@ -5,10 +5,10 @@ CREATE TABLE IF NOT EXISTS route_point ( pol_id INT NOT NULL, -- ID of the POL (Point Of Loading) pod_id INT NOT NULL, -- ID of the POD (Point Of Discharge) latitude FLOAT NOT NULL, -- Value of latitude - longitude FLOAT NOT NULL, -- Value of latitude + longitude FLOAT NOT NULL, -- Value of longitude order INT NOT NULL, -- Order of route point CONSTRAINT route_point_pk PRIMARY KEY (id), CONSTRAINT route_point_pol_fk FOREIGN KEY (pol_id) REFERENCES waypoint (id), CONSTRAINT route_point_pod_fk FOREIGN KEY (pod_id) REFERENCES waypoint (id), - CONSTRAINT unique_route_order UNIQUE (pol_id, pod_id, point_order) + CONSTRAINT unique_route_point_order UNIQUE (pol_id, pod_id, order) ); \ No newline at end of file