Add purchase_order column to acq.edi_message.
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 12 May 2010 20:44:40 +0000 (20:44 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 12 May 2010 20:44:40 +0000 (20:44 +0000)
Also: add the CREATE TABLE command for acq.edi_message (including
the new column) to 200.schema.acq.sql, where it was omitted due
to an oversight.

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/0259.schema.acq-edi-msg-po.sql
M    Open-ILS/examples/fm_IDL.xml

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16423 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/0259.schema.acq-edi-msg-po.sql [new file with mode: 0644]

index bafa1ef..14ebccb 100644 (file)
@@ -5848,9 +5848,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="edi"              reporter:datatype="text"      reporter:label="EDI Message Body"/>
                        <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"/>
                </fields>
                <links>
                        <link field="account" reltype="has_a" key="id" map="" class="acqedi"/>
+                       <link field="purchase_order" reltype="has_a" key="id" map="" class="acqpo"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
index 8abc2a6..d20770b 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 ('0258'); -- Galen Charlton
+INSERT INTO config.upgrade_log (version) VALUES ('0259'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 2293ac1..caf6aa8 100644 (file)
@@ -760,6 +760,33 @@ CREATE TABLE acq.edi_account (      -- similar tables can extend remote_account
 -- We need a UNIQUE constraint here also, to support the FK from acq.provider.edi_default
 ALTER TABLE acq.edi_account ADD CONSTRAINT acq_edi_account_id_unique UNIQUE (id);
 
+CREATE TABLE acq.edi_message (
+    id               SERIAL          PRIMARY KEY,
+    account          INTEGER         REFERENCES acq.edi_account(id)
+                                     DEFERRABLE INITIALLY DEFERRED,
+    remote_file      TEXT,
+    create_time      TIMESTAMPTZ     NOT NULL DEFAULT now(),
+    translate_time   TIMESTAMPTZ,
+    process_time     TIMESTAMPTZ,
+    error_time       TIMESTAMPTZ,
+    status           TEXT            NOT NULL DEFAULT 'new'
+                                     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
+                                        'complete'      -- done
+                                     )),
+    edi              TEXT,
+    jedi             TEXT,
+    error            TEXT,
+    purchase_order   INT             REFERENCES acq.purchase_order
+                                     DEFERRABLE INITIALLY DEFERRED;
+);
+
 -- Note below that the primary key is NOT a SERIAL type.  We will periodically truncate and rebuild
 -- the table, assigning ids programmatically instead of using a sequence.
 CREATE TABLE acq.debit_attribution (
diff --git a/Open-ILS/src/sql/Pg/upgrade/0259.schema.acq-edi-msg-po.sql b/Open-ILS/src/sql/Pg/upgrade/0259.schema.acq-edi-msg-po.sql
new file mode 100644 (file)
index 0000000..dfe97b1
--- /dev/null
@@ -0,0 +1,21 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0259'); -- Scott McKellar
+
+-- Warning: Due to an oversight, the acq.edi_message table was added via an
+-- upgrade script, but the CREATE TABLE statement was never added to the
+-- 200.schema.acq.sql script (till now).
+
+-- If you have rebuilt your system from scratch since then, you may find that
+-- the following ALTER will fail because the table doesn't exist yet.
+
+-- Solution: run the relevant CREATE TABLE statement from 200.schema.acq.sql
+-- instead of this upgrade script.  You may also want to manually insert a
+-- row into config.upgrade_log, as per the above.
+
+ALTER TABLE acq.edi_message
+    ADD COLUMN purchase_order INT
+       REFERENCES acq.purchase_order
+       DEFERRABLE INITIALLY DEFERRED;
+
+COMMIT;