Two changes to acq.edi_message:
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 May 2010 16:47:32 +0000 (16:47 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 17 May 2010 16:47:32 +0000 (16:47 +0000)
1. New "message_type" column.

2. New valid value for status column: 'retry'.

-- WARNING: because the new column is NOT NULL, this upgrade script must
-- initialize it with something if the table is not empty.  The initial
-- value, 'ORDERS', may not always be appropriate.  Massage as needed.

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/0264.schema.acq-edi-message-type.sql
M    Open-ILS/examples/fm_IDL.xml

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

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/200.schema.acq.sql
Open-ILS/src/sql/Pg/upgrade/0264.schema.acq-edi-message-type.sql [new file with mode: 0644]

index 1bef735..1267d84 100644 (file)
@@ -5850,6 +5850,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="jedi"             reporter:datatype="text"      reporter:label="JEDI Message Body"/>
                        <field name="error"            reporter:datatype="text"      reporter:label="Error"/>
                        <field name="purchase_order"   reporter:datatype="link"      reporter:label="Purchase Order"/>
+                       <field name="message_type"     reporter:datatype="text"      reporter:label="Message Type"/>
                </fields>
                <links>
                        <link field="account" reltype="has_a" key="id" map="" class="acqedi"/>
index 103b355..0cba763 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 ('0263'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0264'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 224b281..d17c114 100644 (file)
@@ -778,13 +778,22 @@ CREATE TABLE acq.edi_message (
                                         'processed',    -- needs to have remote_file deleted
                                         'proc_error',   -- error in processing step
                                         'delete_error', -- error in deletion
+                                                                               'retry',        -- need to retry
                                         'complete'      -- done
                                      )),
     edi              TEXT,
     jedi             TEXT,
     error            TEXT,
     purchase_order   INT             REFERENCES acq.purchase_order
-                                     DEFERRABLE INITIALLY DEFERRED
+                                     DEFERRABLE INITIALLY DEFERRED,
+       message_type     TEXT            NOT NULL CONSTRAINT valid_type CHECK
+                                        ( status IN (
+                                                                            'ORDERS',
+                                                                            'ORDRSP',
+                                                                            'INVOIC',
+                                                                            'OSTENQ',
+                                                                            'OSTRPT'
+                                                                        ))
 );
 
 -- Note below that the primary key is NOT a SERIAL type.  We will periodically truncate and rebuild
diff --git a/Open-ILS/src/sql/Pg/upgrade/0264.schema.acq-edi-message-type.sql b/Open-ILS/src/sql/Pg/upgrade/0264.schema.acq-edi-message-type.sql
new file mode 100644 (file)
index 0000000..9bc66e4
--- /dev/null
@@ -0,0 +1,48 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0264'); -- Scott McKellar
+
+-- Add a message_type column
+
+-- WARNING: because the new column is NOT NULL, this upgrade script must
+-- initialize it with something if the table is not empty.  The initial
+-- value, 'ORDERS', may not always be appropriate.  Massage as needed.
+
+ALTER TABLE acq.edi_message
+       ADD COLUMN message_type TEXT;
+
+UPDATE acq.edi_message
+SET message_type = 'ORDERS';
+
+ALTER TABLE acq.edi_message
+       ALTER COLUMN message_type SET NOT NULL;
+
+ALTER TABLE acq.edi_message
+       ADD CONSTRAINT valid_message_type CHECK
+               ( message_type IN (
+                       'ORDERS',
+                       'ORDRSP',
+                       'INVOIC',
+                       'OSTENQ',
+                       'OSTRPT'
+               ));
+
+-- Add a new valid value for status: 'retry'
+
+ALTER TABLE acq.edi_message
+       DROP CONSTRAINT status_value;
+
+ALTER TABLE acq.edi_message
+       ADD CONSTRAINT status_value CHECK
+       ( status IN (
+               'new',          -- needs to be translated
+               'translated',   -- needs to be processed
+               'trans_error',  -- error in translation step
+               'processed',    -- needs to have remote_file deleted
+               'proc_error',   -- error in processing step
+               'delete_error', -- error in deletion
+               'retry',        -- need to retry
+               'complete'      -- done
+       ));
+
+COMMIT;