]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0702.schema.org_unit_opac_vis_and_sorting.sql
LP#1155329: better enforce cat.bib.use_id_for_tcn
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0702.schema.org_unit_opac_vis_and_sorting.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('0702', :eg_version);
4
5 INSERT INTO config.global_flag (name, enabled, label) 
6     VALUES (
7         'opac.org_unit.non_inheritied_visibility',
8         FALSE,
9         oils_i18n_gettext(
10             'opac.org_unit.non_inheritied_visibility',
11             'Org Units Do Not Inherit Visibility',
12             'cgf',
13             'label'
14         )
15     );
16
17 CREATE TYPE actor.org_unit_custom_tree_purpose AS ENUM ('opac');
18
19 CREATE TABLE actor.org_unit_custom_tree (
20     id              SERIAL  PRIMARY KEY,
21     active          BOOLEAN DEFAULT FALSE,
22     purpose         actor.org_unit_custom_tree_purpose NOT NULL DEFAULT 'opac' UNIQUE
23 );
24
25 CREATE TABLE actor.org_unit_custom_tree_node (
26     id              SERIAL  PRIMARY KEY,
27     tree            INTEGER REFERENCES actor.org_unit_custom_tree (id) DEFERRABLE INITIALLY DEFERRED,
28         org_unit        INTEGER NOT NULL REFERENCES actor.org_unit (id) DEFERRABLE INITIALLY DEFERRED,
29         parent_node     INTEGER REFERENCES actor.org_unit_custom_tree_node (id) DEFERRABLE INITIALLY DEFERRED,
30     sibling_order   INTEGER NOT NULL DEFAULT 0,
31     CONSTRAINT aouctn_once_per_org UNIQUE (tree, org_unit)
32 );
33     
34
35 COMMIT;
36
37 /* UNDO
38 BEGIN;
39 DELETE FROM config.global_flag WHERE name = 'opac.org_unit.non_inheritied_visibility';
40 DROP TABLE actor.org_unit_custom_tree_node;
41 DROP TABLE actor.org_unit_custom_tree;
42 DROP TYPE actor.org_unit_custom_tree_purpose;
43 COMMIT;
44 */
45