]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0352.schema.serials-integration.sql
LP#1643709: Stamping upgrade scripts
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0352.schema.serials-integration.sql
1 -- Apply Dan Wells' changes to the serial schema, from the
2 -- seials-integration branch
3
4 BEGIN;
5
6 INSERT INTO config.upgrade_log (version) VALUES ('0352'); -- Scott McKellar
7
8 CREATE TABLE serial.subscription_note (
9         id           SERIAL PRIMARY KEY,
10         subscription INT    NOT NULL
11                             REFERENCES serial.subscription (id)
12                             ON DELETE CASCADE
13                             DEFERRABLE INITIALLY DEFERRED,
14         creator      INT    NOT NULL
15                             REFERENCES actor.usr (id)
16                             DEFERRABLE INITIALLY DEFERRED,
17         create_date  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
18         pub          BOOL   NOT NULL DEFAULT FALSE,
19         title        TEXT   NOT NULL,
20         value        TEXT   NOT NULL
21 );
22
23 ALTER TABLE serial.caption_and_pattern
24 RENAME COLUMN create_time TO create_date;
25
26 ALTER TABLE serial.distribution
27 RENAME COLUMN unit_label_base TO unit_label_prefix;
28
29 CREATE TABLE serial.distribution_note (
30         id           SERIAL PRIMARY KEY,
31         distribution INT    NOT NULL
32                             REFERENCES serial.distribution (id)
33                             ON DELETE CASCADE
34                             DEFERRABLE INITIALLY DEFERRED,
35         creator      INT    NOT NULL
36                             REFERENCES actor.usr (id)
37                             DEFERRABLE INITIALLY DEFERRED,
38         create_date  TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
39         pub          BOOL   NOT NULL DEFAULT FALSE,
40         title        TEXT   NOT NULL,
41         value        TEXT   NOT NULL
42 );
43
44 ALTER TABLE serial.issuance
45 ADD COLUMN caption_and_pattern   INT   REFERENCES serial.caption_and_pattern (id)
46                                        DEFERRABLE INITIALLY DEFERRED;
47 ------- Begin surgery on serial.unit
48
49 ALTER TABLE serial.unit
50         DROP COLUMN label;
51
52 ALTER TABLE serial.unit
53         RENAME COLUMN label_sort_key TO sort_key;
54
55 ALTER TABLE serial.unit
56         RENAME COLUMN contents TO detailed_contents;
57
58 ALTER TABLE serial.unit
59         ADD COLUMN summary_contents TEXT;
60
61 UPDATE serial.unit
62 SET summary_contents = detailed_contents;
63
64 ALTER TABLE serial.unit
65         ALTER column summary_contents SET NOT NULL;
66
67 ------- End surgery on serial.unit
68
69 ALTER TABLE serial.item
70 ADD COLUMN status        TEXT          CONSTRAINT value_status_check CHECK (
71                                        status IN ( 'Bindery', 'Bound', 'Claimed', 'Discarded',
72                                        'Expected', 'Not Held', 'Not Published', 'Received'))
73                                        DEFAULT 'Expected',
74 ADD COLUMN  shadowed     BOOL          NOT NULL DEFAULT FALSE;
75
76 ALTER TABLE serial.bib_summary RENAME TO basic_summary;
77
78 ALTER TABLE serial.sup_summary RENAME TO supplement_summary;
79
80 COMMIT;