From 537c7f8403642e749dcb9268e89da1ee5194ce2d Mon Sep 17 00:00:00 2001 From: scottmk Date: Wed, 12 May 2010 20:44:40 +0000 Subject: [PATCH] Add purchase_order column to acq.edi_message. 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 | 2 ++ Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- Open-ILS/src/sql/Pg/200.schema.acq.sql | 27 +++++++++++++++++++ .../Pg/upgrade/0259.schema.acq-edi-msg-po.sql | 21 +++++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0259.schema.acq-edi-msg-po.sql diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index bafa1ef3c7..14ebccb403 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5848,9 +5848,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 8abc2a6123..d20770bf7f 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 ('0258'); -- Galen Charlton +INSERT INTO config.upgrade_log (version) VALUES ('0259'); -- 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 2293ac1e24..caf6aa8a09 100644 --- a/Open-ILS/src/sql/Pg/200.schema.acq.sql +++ b/Open-ILS/src/sql/Pg/200.schema.acq.sql @@ -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 index 0000000000..dfe97b1e56 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0259.schema.acq-edi-msg-po.sql @@ -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; -- 2.43.2