From ab43731b628302a7d37a03502d99a91e63ff00b0 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Fri, 25 Mar 2022 14:15:55 +0100 Subject: [PATCH 1/3] DDT-991: Requested Equipment Equipment --- datamodel/initdb.d/03_dcsa_im_v3_0.sql | 7 +++++++ datamodel/initdb.d/06_metadata.sql | 3 --- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/datamodel/initdb.d/03_dcsa_im_v3_0.sql b/datamodel/initdb.d/03_dcsa_im_v3_0.sql index 6c2d0a1b..03ece519 100644 --- a/datamodel/initdb.d/03_dcsa_im_v3_0.sql +++ b/datamodel/initdb.d/03_dcsa_im_v3_0.sql @@ -300,6 +300,7 @@ CREATE TABLE dcsa_im_v3_0.iso_equipment_code ( DROP TABLE IF EXISTS dcsa_im_v3_0.requested_equipment CASCADE; CREATE TABLE dcsa_im_v3_0.requested_equipment ( + id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, booking_id uuid NOT NULL REFERENCES dcsa_im_v3_0.booking (id), shipment_id uuid NULL REFERENCES dcsa_im_v3_0.shipment (id), requested_equipment_sizetype varchar(4) NOT NULL REFERENCES dcsa_im_v3_0.iso_equipment_code (iso_equipment_code), @@ -470,6 +471,12 @@ CREATE TABLE dcsa_im_v3_0.equipment ( weight_unit varchar(3) NULL REFERENCES dcsa_im_v3_0.unit_of_measure(unit_of_measure_code) ); +DROP TABLE IF EXISTS dcsa_im_v3_0.requested_equipment_equipment CASCADE; +CREATE TABLE dcsa_im_v3_0.equipment_reference ( + requested_equipment_id uuid NOT NULL REFERENCES dcsa_im_v3_0.requested_equipment(id), + equipment_reference varchar(15) NOT NULL REFERENCES dcsa_im_v3_0.equipment(equipment_reference) +); + -- Supporting FK constraints CREATE INDEX ON dcsa_im_v3_0.equipment (iso_equipment_code); diff --git a/datamodel/initdb.d/06_metadata.sql b/datamodel/initdb.d/06_metadata.sql index e1e28472..53d434c2 100644 --- a/datamodel/initdb.d/06_metadata.sql +++ b/datamodel/initdb.d/06_metadata.sql @@ -39,9 +39,6 @@ ALTER TABLE dcsa_im_v3_0.value_added_service_request ALTER TABLE dcsa_im_v3_0.commodity ADD COLUMN IF NOT EXISTS id uuid DEFAULT uuid_generate_v4() PRIMARY KEY; -ALTER TABLE dcsa_im_v3_0.requested_equipment - ADD COLUMN IF NOT EXISTS id uuid DEFAULT uuid_generate_v4() PRIMARY KEY; - -- DateTime metadata -- Metadata for Booking table to avoid having to query shipmentEvent for From c6c5bf4da0c8243311f1eeb7c3937d4dfca8f42f Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 28 Mar 2022 09:01:29 +0200 Subject: [PATCH 2/3] Update 03_dcsa_im_v3_0.sql --- datamodel/initdb.d/03_dcsa_im_v3_0.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datamodel/initdb.d/03_dcsa_im_v3_0.sql b/datamodel/initdb.d/03_dcsa_im_v3_0.sql index 03ece519..a0cdf4be 100644 --- a/datamodel/initdb.d/03_dcsa_im_v3_0.sql +++ b/datamodel/initdb.d/03_dcsa_im_v3_0.sql @@ -471,15 +471,16 @@ CREATE TABLE dcsa_im_v3_0.equipment ( weight_unit varchar(3) NULL REFERENCES dcsa_im_v3_0.unit_of_measure(unit_of_measure_code) ); +-- Supporting FK constraints +CREATE INDEX ON dcsa_im_v3_0.equipment (iso_equipment_code); +CREATE INDEX ON dcsa_im_v3_0.equipment (equipment_reference); + DROP TABLE IF EXISTS dcsa_im_v3_0.requested_equipment_equipment CASCADE; CREATE TABLE dcsa_im_v3_0.equipment_reference ( requested_equipment_id uuid NOT NULL REFERENCES dcsa_im_v3_0.requested_equipment(id), equipment_reference varchar(15) NOT NULL REFERENCES dcsa_im_v3_0.equipment(equipment_reference) ); --- Supporting FK constraints -CREATE INDEX ON dcsa_im_v3_0.equipment (iso_equipment_code); - DROP TABLE IF EXISTS dcsa_im_v3_0.package_code CASCADE; CREATE TABLE dcsa_im_v3_0.package_code ( package_code varchar(3) PRIMARY KEY, From 35b49dd31d80e30097492e95ef8482888f3a83d7 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Fri, 8 Apr 2022 13:57:08 +0200 Subject: [PATCH 3/3] Update 03_dcsa_im_v3_0.sql --- datamodel/initdb.d/03_dcsa_im_v3_0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datamodel/initdb.d/03_dcsa_im_v3_0.sql b/datamodel/initdb.d/03_dcsa_im_v3_0.sql index a0cdf4be..f2fa5bd7 100644 --- a/datamodel/initdb.d/03_dcsa_im_v3_0.sql +++ b/datamodel/initdb.d/03_dcsa_im_v3_0.sql @@ -476,7 +476,7 @@ CREATE INDEX ON dcsa_im_v3_0.equipment (iso_equipment_code); CREATE INDEX ON dcsa_im_v3_0.equipment (equipment_reference); DROP TABLE IF EXISTS dcsa_im_v3_0.requested_equipment_equipment CASCADE; -CREATE TABLE dcsa_im_v3_0.equipment_reference ( +CREATE TABLE dcsa_im_v3_0.requested_equipment_equipment ( requested_equipment_id uuid NOT NULL REFERENCES dcsa_im_v3_0.requested_equipment(id), equipment_reference varchar(15) NOT NULL REFERENCES dcsa_im_v3_0.equipment(equipment_reference) );