]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql
LP1849212: Users can attach brief bib records and e-resources to courses
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.schema.course-materials-module.sql
1 BEGIN;
2
3 SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
4
5 CREATE TABLE asset.course_module_course (
6     id              SERIAL PRIMARY KEY,
7     name            TEXT NOT NULL,
8     course_number   TEXT NOT NULL,
9     section_number  TEXT,
10     owning_lib      INT REFERENCES actor.org_unit (id),
11     is_archived        BOOLEAN NOT NULL DEFAULT false;
12 );
13
14 CREATE TABLE asset.course_module_course_users (
15     id              SERIAL PRIMARY KEY,
16     course          INT NOT NULL REFERENCES asset.course_module_course (id),
17     usr             INT NOT NULL REFERENCES actor.usr (id),
18     usr_role        TEXT,
19     is_public       BOOLEAN NOT NULL DEFAULT false
20 );
21
22 CREATE TABLE asset.course_module_course_materials (
23     id              SERIAL PRIMARY KEY,
24     course          INT NOT NULL REFERENCES asset.course_module_course (id),
25     item            INT REFERENCES asset.copy (id),
26     relationship    TEXT,
27     record          INT REFERENCES biblio.record_entry (id),
28     temporary_record         BOOLEAN,
29     original_location        INT REFERENCES asset.copy_location,
30     original_status          INT REFERENCES config.copy_status,
31     original_circ_modifier   TEXT, --REFERENCES config.circ_modifier,
32     original_callnumber      INT REFERENCES asset.call_number,
33     unique (course, item, record)
34 );
35
36 INSERT INTO permission.perm_list(id, code, description)
37     VALUES (
38         624,
39         'MANAGE_RESERVES',
40         oils_i18n_gettext(
41             624,
42             'Allows user to manage Courses, Course Materials, and associate Users with Courses.',
43             'ppl',
44             'description'
45         )
46     );
47
48 INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0), (624, 11, 0), (624, 12, 0), (624, 13, 0);
49
50 INSERT INTO config.org_unit_setting_type 
51     (grp, name, datatype, label, description, fm_class)
52 VALUES (
53     'circ',
54     'circ.course_materials_opt_in', 'bool',
55     oils_i18n_gettext(
56         'circ.course_materials_opt_in',
57         'Opt Org Unit into the Course Materials Module',
58         'coust',
59         'label'
60     ),
61     oils_i18n_gettext(
62         'circ.course_materials_opt_in',
63         'If enabled, the Org Unit will utilize Course Material functionality.'
64         'coust',
65         'description'
66     ), null
67 ), (
68     'circ',
69     'circ.course_materials_browse_by_instructor', 'bool',
70     oils_i18n_gettext(
71         'circ.course_materials_browse_by_instructor',
72         'Allow users to browse Courses by Instructor',
73         'coust',
74         'label'
75     ),
76     oils_i18n_gettext(
77         'circ.course_materials_browse_by_instructor',
78         'If enabled, the Org Unit will allow OPAC users to browse Courses by instructor name.'
79         'coust',
80         'description'
81     ), null
82 ), (
83     'circ',
84     'circ.course_materials_brief_record_bib_source', 'link',
85     oils_i18n_gettext(
86         'circ.course_materials_brief_record_bib_source',
87         'Bib source for brief records created in the course materials module',
88         'coust', 'label'
89     ),
90     oils_i18n_gettext(
91         'circ.course_materials_brief_record_bib_source',
92         'The course materials module will use this bib source for any new brief bibliographic records made inside that module. For best results, use a transcendant bib source.',
93         'coust', 'description'
94     ), 'cbs'
95
96 );
97
98 INSERT INTO config.bib_source (quality, source, transcendant) VALUES
99     (1, oils_i18n_gettext(1, 'Course materials module', 'cbs', 'source'), TRUE);
100
101 INSERT INTO actor.org_unit_setting (org_unit, name, value)
102     SELECT 1, 'circ.course_materials_brief_record_bib_source', id
103     FROM config.bib_source
104     WHERE source='Course materials module';
105
106 COMMIT;