<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>
-- 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 (
--- /dev/null
+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;