]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0413.schema.upgrade-auditor-tables.sql
Resolve some discrepancies in the auditor schema between a freshly installed
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0413.schema.upgrade-auditor-tables.sql
1 -- Resolve some discrepancies in the auditor schema between a fresh
2 -- install and an upgraded database.
3
4 BEGIN;
5
6 INSERT INTO config.upgrade_log (version) VALUES ('0413'); -- Scott McKellar
7
8 UPDATE auditor.actor_org_unit_history
9 SET fiscal_calendar = 1
10 WHERE fiscal_calendar IS NULL;
11
12 ALTER TABLE auditor.actor_org_unit_history
13     ALTER COLUMN fiscal_calendar SET NOT NULL;
14
15 DROP VIEW auditor.actor_org_unit_lifecycle;
16
17 SELECT auditor.create_auditor_lifecycle( 'actor', 'org_unit' );
18
19 ALTER TABLE auditor.actor_usr_history
20         ALTER COLUMN claims_never_checked_out_count DROP DEFAULT;
21
22 DROP VIEW auditor.actor_usr_lifecycle;
23
24 SELECT auditor.create_auditor_lifecycle( 'actor', 'usr' );
25
26 UPDATE auditor.asset_call_number_history
27 SET label_class = 1
28 WHERE label_class IS NULL;
29
30 ALTER TABLE auditor.asset_call_number_history
31     ALTER COLUMN label_class SET NOT NULL;
32
33 DROP VIEW auditor.asset_call_number_lifecycle;
34
35 SELECT auditor.create_auditor_lifecycle( 'asset', 'call_number' );
36
37 UPDATE auditor.asset_copy_history
38 SET floating  = false
39 WHERE floating IS NULL;
40
41 ALTER TABLE auditor.asset_copy_history
42         ALTER COLUMN floating SET NOT NULL;
43
44 DROP VIEW auditor.asset_copy_lifecycle;
45
46 SELECT auditor.create_auditor_lifecycle( 'asset', 'copy' );
47
48 DROP VIEW auditor.biblio_record_entry_lifecycle;
49
50 SELECT auditor.create_auditor_lifecycle( 'biblio', 'record_entry' );
51
52 COMMIT;
53
54 -- Outside of transaction; failure is okay if the 
55 -- index already exists
56
57 \qecho Creating some indexes outside of a transaction.  If a CREATE
58 \qecho fails because the index already exists, ignore the failure.
59
60 CREATE INDEX aud_actor_usr_address_hist_id_idx
61         ON auditor.actor_usr_address_history ( id );
62
63 CREATE INDEX aud_actor_usr_hist_id_idx
64     ON auditor.actor_usr_history ( id );
65
66 CREATE INDEX aud_asset_cn_hist_creator_idx
67         ON auditor.asset_call_number_history ( creator );
68
69 CREATE INDEX aud_asset_cn_hist_editor_idx
70         ON auditor.asset_call_number_history ( editor );
71
72 CREATE INDEX aud_asset_cp_hist_creator_idx
73         ON auditor.asset_copy_history ( creator );
74
75 CREATE INDEX aud_asset_cp_hist_editor_idx
76         ON auditor.asset_copy_history ( editor );
77
78 CREATE INDEX aud_bib_rec_entry_hist_creator_idx
79         ON auditor.biblio_record_entry_history ( creator );
80
81 CREATE INDEX aud_bib_rec_entry_hist_editor_idx
82         ON auditor.biblio_record_entry_history ( editor );