LP1952931 stamp upgrade script
authorJane Sandberg <js7389@princeton.edu>
Thu, 27 Oct 2022 22:27:46 +0000 (15:27 -0700)
committerJane Sandberg <js7389@princeton.edu>
Thu, 27 Oct 2022 22:27:46 +0000 (15:27 -0700)
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1345.schema.acq-asn.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql [deleted file]

index b3ebef8..ffa81f5 100644 (file)
@@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1343', :eg_version); -- mrylander/jweston/sandbergja
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1345', :eg_version); -- berick/tlittle/sandbergja
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1345.schema.acq-asn.sql b/Open-ILS/src/sql/Pg/upgrade/1345.schema.acq-asn.sql
new file mode 100644 (file)
index 0000000..1a87429
--- /dev/null
@@ -0,0 +1,70 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1345', :eg_version);
+
+CREATE TABLE acq.shipment_notification (
+    id              SERIAL      PRIMARY KEY,
+    receiver        INT         NOT NULL REFERENCES actor.org_unit (id),
+    provider        INT         NOT NULL REFERENCES acq.provider (id),
+    shipper         INT         NOT NULL REFERENCES acq.provider (id),
+    recv_date       TIMESTAMPTZ NOT NULL DEFAULT NOW(),
+    recv_method     TEXT        NOT NULL REFERENCES acq.invoice_method (code) DEFAULT 'EDI',
+    process_date    TIMESTAMPTZ,
+    processed_by    INT         REFERENCES actor.usr(id) ON DELETE SET NULL,
+    container_code  TEXT        NOT NULL, -- vendor-supplied super-barcode
+    lading_number   TEXT,       -- informational
+    note            TEXT,
+    CONSTRAINT      container_code_once_per_provider UNIQUE(provider, container_code)
+);
+
+CREATE INDEX acq_asn_container_code_idx ON acq.shipment_notification (container_code);
+
+CREATE TABLE acq.shipment_notification_entry (
+    id                      SERIAL  PRIMARY KEY,
+    shipment_notification   INT NOT NULL REFERENCES acq.shipment_notification (id)
+                            ON DELETE CASCADE,
+    lineitem                INT REFERENCES acq.lineitem (id)
+                            ON UPDATE CASCADE ON DELETE SET NULL,
+    item_count              INT NOT NULL -- How many items the provider shipped
+);
+
+/* TODO alter valid_message_type constraint */
+
+ALTER TABLE acq.edi_message DROP CONSTRAINT valid_message_type;
+ALTER TABLE acq.edi_message ADD CONSTRAINT valid_message_type
+CHECK (
+    message_type IN (
+        'ORDERS',
+        'ORDRSP',
+        'INVOIC',
+        'OSTENQ',
+        'OSTRPT',
+        'DESADV'
+    )
+);
+
+COMMIT;
+
+/* UNDO
+
+DELETE FROM acq.edi_message WHERE message_type = 'DESADV';
+
+DELETE FROM acq.shipment_notification_entry;
+DELETE FROM acq.shipment_notification;
+
+ALTER TABLE acq.edi_message DROP CONSTRAINT valid_message_type;
+ALTER TABLE acq.edi_message ADD CONSTRAINT valid_message_type
+CHECK (
+    message_type IN (
+        'ORDERS',
+        'ORDRSP',
+        'INVOIC',
+        'OSTENQ',
+        'OSTRPT'
+    )
+);
+
+DROP TABLE acq.shipment_notification_entry;
+DROP TABLE acq.shipment_notification;
+
+*/
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.acq-asn.sql
deleted file mode 100644 (file)
index ad295b7..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-BEGIN;
-
--- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
-
-CREATE TABLE acq.shipment_notification (
-    id              SERIAL      PRIMARY KEY,
-    receiver        INT         NOT NULL REFERENCES actor.org_unit (id),
-    provider        INT         NOT NULL REFERENCES acq.provider (id),
-    shipper         INT         NOT NULL REFERENCES acq.provider (id),
-    recv_date       TIMESTAMPTZ NOT NULL DEFAULT NOW(),
-    recv_method     TEXT        NOT NULL REFERENCES acq.invoice_method (code) DEFAULT 'EDI',
-    process_date    TIMESTAMPTZ,
-    processed_by    INT         REFERENCES actor.usr(id) ON DELETE SET NULL,
-    container_code  TEXT        NOT NULL, -- vendor-supplied super-barcode
-    lading_number   TEXT,       -- informational
-    note            TEXT,
-    CONSTRAINT      container_code_once_per_provider UNIQUE(provider, container_code)
-);
-
-CREATE INDEX acq_asn_container_code_idx ON acq.shipment_notification (container_code);
-
-CREATE TABLE acq.shipment_notification_entry (
-    id                      SERIAL  PRIMARY KEY,
-    shipment_notification   INT NOT NULL REFERENCES acq.shipment_notification (id)
-                            ON DELETE CASCADE,
-    lineitem                INT REFERENCES acq.lineitem (id)
-                            ON UPDATE CASCADE ON DELETE SET NULL,
-    item_count              INT NOT NULL -- How many items the provider shipped
-);
-
-/* TODO alter valid_message_type constraint */
-
-ALTER TABLE acq.edi_message DROP CONSTRAINT valid_message_type;
-ALTER TABLE acq.edi_message ADD CONSTRAINT valid_message_type
-CHECK (
-    message_type IN (
-        'ORDERS',
-        'ORDRSP',
-        'INVOIC',
-        'OSTENQ',
-        'OSTRPT',
-        'DESADV'
-    )
-);
-
-COMMIT;
-
-/* UNDO
-
-DELETE FROM acq.edi_message WHERE message_type = 'DESADV';
-
-DELETE FROM acq.shipment_notification_entry;
-DELETE FROM acq.shipment_notification;
-
-ALTER TABLE acq.edi_message DROP CONSTRAINT valid_message_type;
-ALTER TABLE acq.edi_message ADD CONSTRAINT valid_message_type
-CHECK (
-    message_type IN (
-        'ORDERS',
-        'ORDRSP',
-        'INVOIC',
-        'OSTENQ',
-        'OSTRPT'
-    )
-);
-
-DROP TABLE acq.shipment_notification_entry;
-DROP TABLE acq.shipment_notification;
-
-*/