Fix a typo in a previous commit to the acq schema. The upgrade script was
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 May 2010 20:12:38 +0000 (20:12 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 18 May 2010 20:12:38 +0000 (20:12 +0000)
correct, but this upgrade script will fix a database table that was built
from the installation script, which was wrong.

M    Open-ILS/src/sql/Pg/200.schema.acq.sql
M    Open-ILS/src/sql/Pg/002.schema.config.sql
A    Open-ILS/src/sql/Pg/upgrade/0266.schema.acq-fix-edi-message-check.sql

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16449 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/upgrade/0266.schema.acq-fix-edi-message-check.sql [new file with mode: 0644]

index 0cba763..6192c22 100644 (file)
@@ -65,7 +65,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0264'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0266'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index d17c114..a1a4b86 100644 (file)
@@ -787,7 +787,7 @@ CREATE TABLE acq.edi_message (
     purchase_order   INT             REFERENCES acq.purchase_order
                                      DEFERRABLE INITIALLY DEFERRED,
        message_type     TEXT            NOT NULL CONSTRAINT valid_type CHECK
-                                        ( status IN (
+                                        ( message_type IN (
                                                                             'ORDERS',
                                                                             'ORDRSP',
                                                                             'INVOIC',
diff --git a/Open-ILS/src/sql/Pg/upgrade/0266.schema.acq-fix-edi-message-check.sql b/Open-ILS/src/sql/Pg/upgrade/0266.schema.acq-fix-edi-message-check.sql
new file mode 100644 (file)
index 0000000..52f5ba8
--- /dev/null
@@ -0,0 +1,22 @@
+BEGIN;
+
+-- Depending on how your edi_message table was created, one of the constraints
+-- may be wrong.  The following will fix it if it's wrong, and have no effect
+-- if it's right.
+
+INSERT INTO config.upgrade_log (version) VALUES ('0266'); -- Scott McKellar
+
+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'
+               ));
+
+COMMIT;