From: Jane Sandberg Date: Mon, 28 Mar 2022 03:09:54 +0000 (-0700) Subject: Stamping upgrade script for OAI-PMH X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=1a07bfb3bdfca6a10db36e2c92ae7c4ea7af21c3;p=Evergreen.git Stamping upgrade script for OAI-PMH --- diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 80c38eab37..e36d5f3c2a 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 ('1322', :eg_version); -- rhamby/miker +INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1323', :eg_version); -- lucien/remingtron/sandbergja/gmcharlt/miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/1323.schema.oai.sql b/Open-ILS/src/sql/Pg/upgrade/1323.schema.oai.sql new file mode 100644 index 0000000000..d289ba86bc --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/1323.schema.oai.sql @@ -0,0 +1,49 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('1323', :eg_version); + +-- VIEWS for the oai service +CREATE SCHEMA oai; + +-- The view presents a lean table with unique bre.tc-numbers for oai paging; +CREATE VIEW oai.biblio AS + SELECT + bre.id AS rec_id, + bre.edit_date AT TIME ZONE 'UTC' AS datestamp, + bre.deleted AS deleted + FROM + biblio.record_entry bre + ORDER BY + bre.id; + +-- The view presents a lean table with unique are.tc-numbers for oai paging; +CREATE VIEW oai.authority AS + SELECT + are.id AS rec_id, + are.edit_date AT TIME ZONE 'UTC' AS datestamp, + are.deleted AS deleted + FROM + authority.record_entry AS are + ORDER BY + are.id; + +CREATE OR REPLACE function oai.bib_is_visible_at_org_by_copy(bib BIGINT, org INT) RETURNS BOOL AS $F$ +WITH corgs AS (SELECT array_agg(id) AS list FROM actor.org_unit_descendants(org)) + SELECT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache, corgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('circ_lib', corgs.list)::query_int AND bib=record) +$F$ LANGUAGE SQL STABLE; + +CREATE OR REPLACE function oai.bib_is_visible_at_org_by_luri(bib BIGINT, org INT) RETURNS BOOL AS $F$ +WITH lorgs AS(SELECT array_agg(id) AS list FROM actor.org_unit_ancestors(org)) + SELECT EXISTS (SELECT 1 FROM biblio.record_entry, lorgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('luri_org', lorgs.list)::query_int AND bib=id) +$F$ LANGUAGE SQL STABLE; + +CREATE OR REPLACE function oai.bib_is_visible_by_source(bib BIGINT, src TEXT) RETURNS BOOL AS $F$ + SELECT EXISTS (SELECT 1 FROM biblio.record_entry b JOIN config.bib_source s ON (b.source = s.id) WHERE transcendant AND s.source = src AND bib=b.id) +$F$ LANGUAGE SQL STABLE; + +CREATE OR REPLACE function oai.auth_is_visible_by_axis(auth BIGINT, ax TEXT) RETURNS BOOL AS $F$ + SELECT EXISTS (SELECT 1 FROM authority.browse_axis_authority_field_map m JOIN authority.simple_heading r on (r.atag = m.field AND r.record = auth AND m.axis = ax)) +$F$ LANGUAGE SQL STABLE; + +COMMIT; + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql deleted file mode 100644 index b81ffb6ec7..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.oai_views.sql +++ /dev/null @@ -1,49 +0,0 @@ -BEGIN; - -SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); - --- VIEWS for the oai service -CREATE SCHEMA oai; - --- The view presents a lean table with unique bre.tc-numbers for oai paging; -CREATE VIEW oai.biblio AS - SELECT - bre.id AS rec_id, - bre.edit_date AT TIME ZONE 'UTC' AS datestamp, - bre.deleted AS deleted - FROM - biblio.record_entry bre - ORDER BY - bre.id; - --- The view presents a lean table with unique are.tc-numbers for oai paging; -CREATE VIEW oai.authority AS - SELECT - are.id AS rec_id, - are.edit_date AT TIME ZONE 'UTC' AS datestamp, - are.deleted AS deleted - FROM - authority.record_entry AS are - ORDER BY - are.id; - -CREATE OR REPLACE function oai.bib_is_visible_at_org_by_copy(bib BIGINT, org INT) RETURNS BOOL AS $F$ -WITH corgs AS (SELECT array_agg(id) AS list FROM actor.org_unit_descendants(org)) - SELECT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache, corgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('circ_lib', corgs.list)::query_int AND bib=record) -$F$ LANGUAGE SQL STABLE; - -CREATE OR REPLACE function oai.bib_is_visible_at_org_by_luri(bib BIGINT, org INT) RETURNS BOOL AS $F$ -WITH lorgs AS(SELECT array_agg(id) AS list FROM actor.org_unit_ancestors(org)) - SELECT EXISTS (SELECT 1 FROM biblio.record_entry, lorgs WHERE vis_attr_vector @@ search.calculate_visibility_attribute_test('luri_org', lorgs.list)::query_int AND bib=id) -$F$ LANGUAGE SQL STABLE; - -CREATE OR REPLACE function oai.bib_is_visible_by_source(bib BIGINT, src TEXT) RETURNS BOOL AS $F$ - SELECT EXISTS (SELECT 1 FROM biblio.record_entry b JOIN config.bib_source s ON (b.source = s.id) WHERE transcendant AND s.source = src AND bib=b.id) -$F$ LANGUAGE SQL STABLE; - -CREATE OR REPLACE function oai.auth_is_visible_by_axis(auth BIGINT, ax TEXT) RETURNS BOOL AS $F$ - SELECT EXISTS (SELECT 1 FROM authority.browse_axis_authority_field_map m JOIN authority.simple_heading r on (r.atag = m.field AND r.record = auth AND m.axis = ax)) -$F$ LANGUAGE SQL STABLE; - -COMMIT; -