]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0133.schema.config_accounts_and_acq_edi.sql
Break up expensive queries, match index to quals
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0133.schema.config_accounts_and_acq_edi.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0133'); -- atz
4
5 CREATE TABLE config.remote_account (
6     id          SERIAL  PRIMARY KEY,
7     label       TEXT    NOT NULL,
8     host        TEXT    NOT NULL,   -- name or IP, :port optional
9     username    TEXT,               -- optional, since we could default to $USER
10     password    TEXT,               -- optional, since we could use SSH keys, or anonymous login.
11     account     TEXT,               -- aka profile or FTP "account" command
12     path        TEXT,               -- aka directory
13     owner       INT     NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
14     last_activity TIMESTAMP WITH TIME ZONE
15 );
16
17 CREATE TABLE acq.edi_account (      -- similar tables can extend remote_account for other parts of EG
18     provider    INT     NOT NULL REFERENCES acq.provider          (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED,
19     in_dir      TEXT    -- incoming messages dir (probably different than config.remote_account.path, the outgoing dir)
20 ) INHERITS (config.remote_account);
21
22 -- We need a UNIQUE constraint here also, to support the FK in the next command
23 ALTER TABLE acq.edi_account ADD CONSTRAINT acq_edi_account_id_unique UNIQUE (id);
24
25 -- null edi_default is OK... it has to be, since we have no values in acq.edi_account yet
26 ALTER TABLE acq.provider ADD COLUMN edi_default INT REFERENCES acq.edi_account (id) DEFERRABLE INITIALLY DEFERRED;
27
28 COMMIT;