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 new file mode 100644 index 0000000..c3affe5 --- /dev/null +++ b/sql/voyage/route_point_create.sql @@ -0,0 +1,14 @@ +DROP TABLE IF EXISTS route_point; + +CREATE TABLE IF NOT EXISTS 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 + 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_point_order UNIQUE (pol_id, pod_id, order) +); \ No newline at end of file