From: Mike Rylander Date: Thu, 24 Mar 2022 19:17:39 +0000 (-0400) Subject: Stamping upgrade script for Simple Reporter (permission ID adjusted) X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=15ecabc43187a85e9913adb880832f430a7d6ed2;p=contrib%2FConifer.git Stamping upgrade script for Simple Reporter (permission ID adjusted) Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 12f7e53117..fc6c692886 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 ('1319', :eg_version); -- berick/miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1320', :eg_version); -- jboyer/miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1320.schema.simple_reporter.sql b/Open-ILS/src/sql/Pg/upgrade/1320.schema.simple_reporter.sql new file mode 100644 index 0000000000..985a1d6212 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1320.schema.simple_reporter.sql @@ -0,0 +1,71 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1320', :eg_version); -- jboyer / / + +ALTER TABLE reporter.template_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; +ALTER TABLE reporter.report_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; +ALTER TABLE reporter.output_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; + +DROP INDEX reporter.rpt_template_folder_once_idx; +DROP INDEX reporter.rpt_report_folder_once_idx; +DROP INDEX reporter.rpt_output_folder_once_idx; + +CREATE UNIQUE INDEX rpt_template_folder_once_idx ON reporter.template_folder (name,owner,simple_reporter) WHERE parent IS NULL; +CREATE UNIQUE INDEX rpt_report_folder_once_idx ON reporter.report_folder (name,owner,simple_reporter) WHERE parent IS NULL; +CREATE UNIQUE INDEX rpt_output_folder_once_idx ON reporter.output_folder (name,owner,simple_reporter) WHERE parent IS NULL; + +-- Private "transform" to allow for simple report permissions verification +CREATE OR REPLACE FUNCTION reporter.intersect_user_perm_ou(context_ou BIGINT, staff_id BIGINT, perm_code TEXT) +RETURNS BOOLEAN AS $$ + SELECT CASE WHEN context_ou IN (SELECT * FROM permission.usr_has_perm_at_all(staff_id::INT, perm_code)) THEN TRUE ELSE FALSE END; +$$ LANGUAGE SQL; + +-- Hey committer, make sure this id is good to go and also in 950.data.seed-values.sql +INSERT INTO permission.perm_list (id, code, description) VALUES + ( 638, 'RUN_SIMPLE_REPORTS', oils_i18n_gettext(638, + 'Build and run simple reports', 'ppl', 'description')); + + +INSERT INTO config.workstation_setting_type (name, grp, datatype, label) +VALUES ( + 'eg.grid.reporter.simple.reports', 'gui', 'object', + oils_i18n_gettext( + 'eg.grid.reporter.simple.reports', + 'Grid Config: eg.grid.reporter.simple.reports', + 'cwst', 'label' + ) +), ( + 'eg.grid.reporter.simple.outputs', 'gui', 'object', + oils_i18n_gettext( + 'eg.grid.reporter.simple.outputs', + 'Grid Config: eg.grid.reporter.simple.outputs', + 'cwst', 'label' + ) +); + +-- new view parallel to reporter.currently_running +-- and reporter.overdue_reports +CREATE OR REPLACE VIEW reporter.completed_reports AS + SELECT s.id AS run, + r.id AS report, + t.id AS template, + t.owner AS template_owner, + r.owner AS report_owner, + s.runner AS runner, + t.folder AS template_folder, + r.folder AS report_folder, + s.folder AS output_folder, + r.name AS report_name, + t.name AS template_name, + s.start_time, + s.run_time, + s.complete_time, + s.error_code, + s.error_text + FROM reporter.schedule s + JOIN reporter.report r ON r.id = s.report + JOIN reporter.template t ON t.id = r.template + WHERE s.complete_time IS NOT NULL; + +COMMIT; + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.simple_reporter.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.simple_reporter.sql deleted file mode 100644 index a06d641d41..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.simple_reporter.sql +++ /dev/null @@ -1,71 +0,0 @@ -BEGIN; - --- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -- jboyer / / - -ALTER TABLE reporter.template_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; -ALTER TABLE reporter.report_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; -ALTER TABLE reporter.output_folder ADD COLUMN simple_reporter BOOLEAN DEFAULT FALSE; - -DROP INDEX reporter.rpt_template_folder_once_idx; -DROP INDEX reporter.rpt_report_folder_once_idx; -DROP INDEX reporter.rpt_output_folder_once_idx; - -CREATE UNIQUE INDEX rpt_template_folder_once_idx ON reporter.template_folder (name,owner,simple_reporter) WHERE parent IS NULL; -CREATE UNIQUE INDEX rpt_report_folder_once_idx ON reporter.report_folder (name,owner,simple_reporter) WHERE parent IS NULL; -CREATE UNIQUE INDEX rpt_output_folder_once_idx ON reporter.output_folder (name,owner,simple_reporter) WHERE parent IS NULL; - --- Private "transform" to allow for simple report permissions verification -CREATE OR REPLACE FUNCTION reporter.intersect_user_perm_ou(context_ou BIGINT, staff_id BIGINT, perm_code TEXT) -RETURNS BOOLEAN AS $$ - SELECT CASE WHEN context_ou IN (SELECT * FROM permission.usr_has_perm_at_all(staff_id::INT, perm_code)) THEN TRUE ELSE FALSE END; -$$ LANGUAGE SQL; - --- Hey committer, make sure this id is good to go and also in 950.data.seed-values.sql -INSERT INTO permission.perm_list (id, code, description) VALUES - ( 636, 'RUN_SIMPLE_REPORTS', oils_i18n_gettext(636, - 'Build and run simple reports', 'ppl', 'description')); - - -INSERT INTO config.workstation_setting_type (name, grp, datatype, label) -VALUES ( - 'eg.grid.reporter.simple.reports', 'gui', 'object', - oils_i18n_gettext( - 'eg.grid.reporter.simple.reports', - 'Grid Config: eg.grid.reporter.simple.reports', - 'cwst', 'label' - ) -), ( - 'eg.grid.reporter.simple.outputs', 'gui', 'object', - oils_i18n_gettext( - 'eg.grid.reporter.simple.outputs', - 'Grid Config: eg.grid.reporter.simple.outputs', - 'cwst', 'label' - ) -); - --- new view parallel to reporter.currently_running --- and reporter.overdue_reports -CREATE OR REPLACE VIEW reporter.completed_reports AS - SELECT s.id AS run, - r.id AS report, - t.id AS template, - t.owner AS template_owner, - r.owner AS report_owner, - s.runner AS runner, - t.folder AS template_folder, - r.folder AS report_folder, - s.folder AS output_folder, - r.name AS report_name, - t.name AS template_name, - s.start_time, - s.run_time, - s.complete_time, - s.error_code, - s.error_text - FROM reporter.schedule s - JOIN reporter.report r ON r.id = s.report - JOIN reporter.template t ON t.id = r.template - WHERE s.complete_time IS NOT NULL; - -COMMIT; -