From: scottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 17 May 2010 16:47:32 +0000 (+0000)
Subject: Two changes to acq.edi_message:
X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a90c7523d49fe476185f12a4efae9de4d14d6d88;p=evergreen%2Fmasslnc.git

Two changes to acq.edi_message:

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
---

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index 1bef735cda..1267d84b10 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -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"/>
diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 103b3551ed..0cba763e69 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -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,
diff --git a/Open-ILS/src/sql/Pg/200.schema.acq.sql b/Open-ILS/src/sql/Pg/200.schema.acq.sql
index 224b2814ae..d17c114265 100644
--- a/Open-ILS/src/sql/Pg/200.schema.acq.sql
+++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql
@@ -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
index 0000000000..9bc66e4d43
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/0264.schema.acq-edi-message-type.sql
@@ -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;