]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0210.schema.acq.claim-policy.sql
Create two tables in acq schema: claim_policy and claim_policy_action.
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0210.schema.acq.claim-policy.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0210'); -- Scott McKellar
4
5 CREATE TABLE acq.claim_policy (
6         id              SERIAL       PRIMARY KEY,
7         org_unit        INT          NOT NULL REFERENCES actor.org_unit
8                                      DEFERRABLE INITIALLY DEFERRED,
9         name            TEXT         NOT NULL,
10         description     TEXT         NOT NULL,
11         CONSTRAINT name_once_per_org UNIQUE (org_unit, name)
12 );
13
14 CREATE TABLE acq.claim_policy_action (
15         id              SERIAL       PRIMARY KEY,
16         claim_policy    INT          NOT NULL REFERENCES acq.claim_policy
17                                  ON DELETE CASCADE
18                                      DEFERRABLE INITIALLY DEFERRED,
19         action_interval INTERVAL     NOT NULL,
20         action          INT          NOT NULL REFERENCES acq.claim_event_type
21                                      DEFERRABLE INITIALLY DEFERRED,
22         CONSTRAINT action_sequence UNIQUE (claim_policy, action_interval)
23 );
24
25 COMMIT;