From: Kathy Lussier Date: Wed, 17 Jan 2018 18:25:11 +0000 (-0500) Subject: LP#1743650: Stamping upgrade script for special bib visibility handling X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b30ae376ef5d23f5133fe80e5d10a95edc273857;p=working%2FEvergreen.git LP#1743650: Stamping upgrade script for special bib visibility handling Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 650c5ec461..6dbde67221 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 ('1086', :eg_version); -- miker/kmlussier +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1087', :eg_version); -- miker/kmlussier CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1087.function.special-bib-vis-handling.sql b/Open-ILS/src/sql/Pg/upgrade/1087.function.special-bib-vis-handling.sql new file mode 100644 index 0000000000..c98a109fb4 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1087.function.special-bib-vis-handling.sql @@ -0,0 +1,51 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1087', :eg_version); + +CREATE OR REPLACE FUNCTION asset.patron_default_visibility_mask () RETURNS TABLE (b_attrs TEXT, c_attrs TEXT) AS $f$ +DECLARE + copy_flags TEXT; -- "c" attr + + owning_lib TEXT; -- "c" attr + circ_lib TEXT; -- "c" attr + status TEXT; -- "c" attr + location TEXT; -- "c" attr + location_group TEXT; -- "c" attr + + luri_org TEXT; -- "b" attr + bib_sources TEXT; -- "b" attr + + bib_tests TEXT := ''; +BEGIN + copy_flags := asset.all_visible_flags(); -- Will always have at least one + + owning_lib := NULLIF(asset.owning_lib_default(),'!()'); + + circ_lib := NULLIF(asset.circ_lib_default(),'!()'); + status := NULLIF(asset.status_default(),'!()'); + location := NULLIF(asset.location_default(),'!()'); + location_group := NULLIF(asset.location_group_default(),'!()'); + + -- LURIs will be handled at the perl layer directly + -- luri_org := NULLIF(asset.luri_org_default(),'!()'); + bib_sources := NULLIF(asset.bib_source_default(),'()'); + + + IF luri_org IS NOT NULL AND bib_sources IS NOT NULL THEN + bib_tests := '('||ARRAY_TO_STRING( ARRAY[luri_org,bib_sources], '|')||')&('||luri_org||')&'; + ELSIF luri_org IS NOT NULL THEN + bib_tests := luri_org || '&'; + ELSIF bib_sources IS NOT NULL THEN + bib_tests := bib_sources || '|'; + END IF; + + RETURN QUERY SELECT bib_tests, + '('||ARRAY_TO_STRING( + ARRAY[copy_flags,owning_lib,circ_lib,status,location,location_group]::TEXT[], + '&' + )||')'; +END; +$f$ LANGUAGE PLPGSQL STABLE ROWS 1; + +COMMIT; + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.special-bib-vis-handling.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.special-bib-vis-handling.sql deleted file mode 100644 index 11c5a2d098..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.special-bib-vis-handling.sql +++ /dev/null @@ -1,49 +0,0 @@ -BEGIN; - -CREATE OR REPLACE FUNCTION asset.patron_default_visibility_mask () RETURNS TABLE (b_attrs TEXT, c_attrs TEXT) AS $f$ -DECLARE - copy_flags TEXT; -- "c" attr - - owning_lib TEXT; -- "c" attr - circ_lib TEXT; -- "c" attr - status TEXT; -- "c" attr - location TEXT; -- "c" attr - location_group TEXT; -- "c" attr - - luri_org TEXT; -- "b" attr - bib_sources TEXT; -- "b" attr - - bib_tests TEXT := ''; -BEGIN - copy_flags := asset.all_visible_flags(); -- Will always have at least one - - owning_lib := NULLIF(asset.owning_lib_default(),'!()'); - - circ_lib := NULLIF(asset.circ_lib_default(),'!()'); - status := NULLIF(asset.status_default(),'!()'); - location := NULLIF(asset.location_default(),'!()'); - location_group := NULLIF(asset.location_group_default(),'!()'); - - -- LURIs will be handled at the perl layer directly - -- luri_org := NULLIF(asset.luri_org_default(),'!()'); - bib_sources := NULLIF(asset.bib_source_default(),'()'); - - - IF luri_org IS NOT NULL AND bib_sources IS NOT NULL THEN - bib_tests := '('||ARRAY_TO_STRING( ARRAY[luri_org,bib_sources], '|')||')&('||luri_org||')&'; - ELSIF luri_org IS NOT NULL THEN - bib_tests := luri_org || '&'; - ELSIF bib_sources IS NOT NULL THEN - bib_tests := bib_sources || '|'; - END IF; - - RETURN QUERY SELECT bib_tests, - '('||ARRAY_TO_STRING( - ARRAY[copy_flags,owning_lib,circ_lib,status,location,location_group]::TEXT[], - '&' - )||')'; -END; -$f$ LANGUAGE PLPGSQL STABLE ROWS 1; - -COMMIT; -