From: Galen Charlton Date: Tue, 15 Sep 2020 01:21:55 +0000 (-0400) Subject: LP#1849212: stamp schema update X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e1c1bbfb19013565191062ef369ec99e30cc9b05;p=Evergreen.git LP#1849212: stamp schema update Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 483c5faeab..6dab77eea1 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps BEFORE INSERT OR UPDATE ON config.db_patch_dependencies FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates'); -INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1231', :eg_version); -- miker/mmorgan/gmcharlt +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1232', :eg_version); -- khuckins/sandbergja/JBoyer/mmorgan/gmcharlt CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1232.schema.course-materials-module.sql b/Open-ILS/src/sql/Pg/upgrade/1232.schema.course-materials-module.sql new file mode 100644 index 0000000000..37d909d44e --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1232.schema.course-materials-module.sql @@ -0,0 +1,132 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1232', :eg_version); + +CREATE TABLE asset.course_module_course ( + id SERIAL PRIMARY KEY, + name TEXT NOT NULL, + course_number TEXT NOT NULL, + section_number TEXT, + owning_lib INT REFERENCES actor.org_unit (id), + is_archived BOOLEAN NOT NULL DEFAULT false +); + +CREATE TABLE asset.course_module_role ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + is_public BOOLEAN NOT NULL DEFAULT false +); + +CREATE TABLE asset.course_module_course_users ( + id SERIAL PRIMARY KEY, + course INT NOT NULL REFERENCES asset.course_module_course (id), + usr INT NOT NULL REFERENCES actor.usr (id), + usr_role INT REFERENCES asset.course_module_role (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +); + +CREATE TABLE asset.course_module_course_materials ( + id SERIAL PRIMARY KEY, + course INT NOT NULL REFERENCES asset.course_module_course (id), + item INT REFERENCES asset.copy (id), + relationship TEXT, + record INT REFERENCES biblio.record_entry (id), + temporary_record BOOLEAN, + original_location INT REFERENCES asset.copy_location, + original_status INT REFERENCES config.copy_status, + original_circ_modifier TEXT, --REFERENCES config.circ_modifier + original_callnumber INT REFERENCES asset.call_number, + unique (course, item, record) +); + +CREATE TABLE asset.course_module_term ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + owning_lib INT REFERENCES actor.org_unit (id), + start_date TIMESTAMP WITH TIME ZONE, + end_date TIMESTAMP WITH TIME ZONE +); + +INSERT INTO asset.course_module_role (id, name, is_public) VALUES +(1, oils_i18n_gettext(1, 'Instructor', 'acmr', 'name'), true), +(2, oils_i18n_gettext(2, 'Teaching assistant', 'acmr', 'name'), true), +(3, oils_i18n_gettext(2, 'Student', 'acmr', 'name'), false); + +SELECT SETVAL('asset.course_module_role_id_seq'::TEXT, 100); + +CREATE TABLE asset.course_module_term_course_map ( + id BIGSERIAL PRIMARY KEY, + term INT NOT NULL REFERENCES asset.course_module_term (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + course INT NOT NULL REFERENCES asset.course_module_course (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +); + +INSERT INTO permission.perm_list(id, code, description) + VALUES ( + 624, + 'MANAGE_RESERVES', + oils_i18n_gettext( + 624, + 'Allows user to manage Courses, Course Materials, and associate Users with Courses.', + 'ppl', + 'description' + ) + ); + +INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0), (624, 11, 0), (624, 12, 0), (624, 13, 0); + +INSERT INTO config.org_unit_setting_type + (grp, name, datatype, label, description, fm_class) +VALUES ( + 'circ', + 'circ.course_materials_opt_in', 'bool', + oils_i18n_gettext( + 'circ.course_materials_opt_in', + 'Opt Org Unit into the Course Materials Module', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.course_materials_opt_in', + 'If enabled, the Org Unit will utilize Course Material functionality.', + 'coust', + 'description' + ), null +), ( + 'circ', + 'circ.course_materials_browse_by_instructor', 'bool', + oils_i18n_gettext( + 'circ.course_materials_browse_by_instructor', + 'Allow users to browse Courses by Instructor', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.course_materials_browse_by_instructor', + 'If enabled, the Org Unit will allow OPAC users to browse Courses by instructor name.', + 'coust', + 'description' + ), null +), ( + 'circ', + 'circ.course_materials_brief_record_bib_source', 'link', + oils_i18n_gettext( + 'circ.course_materials_brief_record_bib_source', + 'Bib source for brief records created in the course materials module', + 'coust', 'label' + ), + oils_i18n_gettext( + 'circ.course_materials_brief_record_bib_source', + '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.', + 'coust', 'description' + ), 'cbs' + +); + +INSERT INTO config.bib_source (quality, source, transcendant) VALUES + (1, oils_i18n_gettext(4, 'Course materials module', 'cbs', 'source'), TRUE); + +INSERT INTO actor.org_unit_setting (org_unit, name, value) + SELECT 1, 'circ.course_materials_brief_record_bib_source', id + FROM config.bib_source + WHERE source='Course materials module'; + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql deleted file mode 100644 index 8699d37519..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql +++ /dev/null @@ -1,132 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - -CREATE TABLE asset.course_module_course ( - id SERIAL PRIMARY KEY, - name TEXT NOT NULL, - course_number TEXT NOT NULL, - section_number TEXT, - owning_lib INT REFERENCES actor.org_unit (id), - is_archived BOOLEAN NOT NULL DEFAULT false -); - -CREATE TABLE asset.course_module_role ( - id SERIAL PRIMARY KEY, - name TEXT UNIQUE NOT NULL, - is_public BOOLEAN NOT NULL DEFAULT false -); - -CREATE TABLE asset.course_module_course_users ( - id SERIAL PRIMARY KEY, - course INT NOT NULL REFERENCES asset.course_module_course (id), - usr INT NOT NULL REFERENCES actor.usr (id), - usr_role INT REFERENCES asset.course_module_role (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED -); - -CREATE TABLE asset.course_module_course_materials ( - id SERIAL PRIMARY KEY, - course INT NOT NULL REFERENCES asset.course_module_course (id), - item INT REFERENCES asset.copy (id), - relationship TEXT, - record INT REFERENCES biblio.record_entry (id), - temporary_record BOOLEAN, - original_location INT REFERENCES asset.copy_location, - original_status INT REFERENCES config.copy_status, - original_circ_modifier TEXT, --REFERENCES config.circ_modifier - original_callnumber INT REFERENCES asset.call_number, - unique (course, item, record) -); - -CREATE TABLE asset.course_module_term ( - id SERIAL PRIMARY KEY, - name TEXT UNIQUE NOT NULL, - owning_lib INT REFERENCES actor.org_unit (id), - start_date TIMESTAMP WITH TIME ZONE, - end_date TIMESTAMP WITH TIME ZONE -); - -INSERT INTO asset.course_module_role (id, name, is_public) VALUES -(1, oils_i18n_gettext(1, 'Instructor', 'acmr', 'name'), true), -(2, oils_i18n_gettext(2, 'Teaching assistant', 'acmr', 'name'), true), -(3, oils_i18n_gettext(2, 'Student', 'acmr', 'name'), false); - -SELECT SETVAL('asset.course_module_role_id_seq'::TEXT, 100); - -CREATE TABLE asset.course_module_term_course_map ( - id BIGSERIAL PRIMARY KEY, - term INT NOT NULL REFERENCES asset.course_module_term (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, - course INT NOT NULL REFERENCES asset.course_module_course (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED -); - -INSERT INTO permission.perm_list(id, code, description) - VALUES ( - 624, - 'MANAGE_RESERVES', - oils_i18n_gettext( - 624, - 'Allows user to manage Courses, Course Materials, and associate Users with Courses.', - 'ppl', - 'description' - ) - ); - -INSERT INTO permission.grp_perm_map(perm, grp, depth) VALUES (624, 9, 0), (624, 11, 0), (624, 12, 0), (624, 13, 0); - -INSERT INTO config.org_unit_setting_type - (grp, name, datatype, label, description, fm_class) -VALUES ( - 'circ', - 'circ.course_materials_opt_in', 'bool', - oils_i18n_gettext( - 'circ.course_materials_opt_in', - 'Opt Org Unit into the Course Materials Module', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'circ.course_materials_opt_in', - 'If enabled, the Org Unit will utilize Course Material functionality.', - 'coust', - 'description' - ), null -), ( - 'circ', - 'circ.course_materials_browse_by_instructor', 'bool', - oils_i18n_gettext( - 'circ.course_materials_browse_by_instructor', - 'Allow users to browse Courses by Instructor', - 'coust', - 'label' - ), - oils_i18n_gettext( - 'circ.course_materials_browse_by_instructor', - 'If enabled, the Org Unit will allow OPAC users to browse Courses by instructor name.', - 'coust', - 'description' - ), null -), ( - 'circ', - 'circ.course_materials_brief_record_bib_source', 'link', - oils_i18n_gettext( - 'circ.course_materials_brief_record_bib_source', - 'Bib source for brief records created in the course materials module', - 'coust', 'label' - ), - oils_i18n_gettext( - 'circ.course_materials_brief_record_bib_source', - '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.', - 'coust', 'description' - ), 'cbs' - -); - -INSERT INTO config.bib_source (quality, source, transcendant) VALUES - (1, oils_i18n_gettext(4, 'Course materials module', 'cbs', 'source'), TRUE); - -INSERT INTO actor.org_unit_setting (org_unit, name, value) - SELECT 1, 'circ.course_materials_brief_record_bib_source', id - FROM config.bib_source - WHERE source='Course materials module'; - -COMMIT;