]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0360.schema.acq-serials-integration.sql
LP#1178377: Make bib source optional element from unapi.bre
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0360.schema.acq-serials-integration.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0360'); -- miker
4
5 INSERT INTO acq.invoice_item_type (code,name) VALUES ('SUB',oils_i18n_gettext('SUB', 'Searial Subscription', 'aiit', 'name'));
6
7 ALTER TABLE acq.po_item ADD COLUMN target BIGINT;
8 ALTER TABLE acq.invoice_item ADD COLUMN target BIGINT;
9 ALTER TABLE asset.copy ADD COLUMN cost NUMERIC(8,2);
10
11 CREATE TABLE acq.serial_claim (
12     id     SERIAL           PRIMARY KEY,
13     type   INT              NOT NULL REFERENCES acq.claim_type
14                                      DEFERRABLE INITIALLY DEFERRED,
15     item    BIGINT          NOT NULL REFERENCES serial.item
16                                      DEFERRABLE INITIALLY DEFERRED
17 );
18
19 CREATE INDEX serial_claim_lid_idx ON acq.serial_claim( item );
20
21 CREATE TABLE acq.serial_claim_event (
22     id             BIGSERIAL        PRIMARY KEY,
23     type           INT              NOT NULL REFERENCES acq.claim_event_type
24                                              DEFERRABLE INITIALLY DEFERRED,
25     claim          SERIAL           NOT NULL REFERENCES acq.serial_claim
26                                              DEFERRABLE INITIALLY DEFERRED,
27     event_date     TIMESTAMPTZ      NOT NULL DEFAULT now(),
28     creator        INT              NOT NULL REFERENCES actor.usr
29                                              DEFERRABLE INITIALLY DEFERRED,
30     note           TEXT
31 );
32
33 CREATE INDEX serial_claim_event_claim_date_idx ON acq.serial_claim_event( claim, event_date );
34
35 COMMIT;
36