Skip to content
3 changes: 3 additions & 0 deletions sql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 16 additions & 0 deletions sql/voyage/route_point_create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
DROP TABLE IF EXISTS route_point;

CREATE TABLE IF NOT EXISTS route_point (
id INT GENERATED ALWAYS AS IDENTITY, -- ID of the route point
project_id INT, -- ID of the project
ship_id INT, -- ID of the ship
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 longitude
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 port (id),
CONSTRAINT route_point_pod_fk FOREIGN KEY (pod_id) REFERENCES port (id),
CONSTRAINT unique_route_point_order UNIQUE (project_id, ship_id, pol_id, pod_id, point_order) DEFERRABLE INITIALLY DEFERRED
);