diff --git a/datamodel/initdb.d/03_dcsa_im_v3_0.sql b/datamodel/initdb.d/03_dcsa_im_v3_0.sql index 6c2d0a1b..f2fa5bd7 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), @@ -472,6 +473,13 @@ CREATE TABLE dcsa_im_v3_0.equipment ( -- 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.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) +); DROP TABLE IF EXISTS dcsa_im_v3_0.package_code CASCADE; CREATE TABLE dcsa_im_v3_0.package_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