LP#1718300: fold update into 2.12.5-3.0-beta schema update
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 20 Sep 2017 21:48:33 +0000 (17:48 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 20 Sep 2017 21:49:53 +0000 (17:49 -0400)
This saves a step for building the beta2 release, as
2.12.5-3.0-beta1-upgrade-db.sql will be moved to
2.12.5-3.0-beta2-upgrade-db.sql.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/sql/Pg/version-upgrade/2.12.5-3.0-beta1-upgrade-db.sql

index 0da1859..d10e316 100644 (file)
@@ -1867,6 +1867,9 @@ BEGIN
 END;
 $f$ LANGUAGE PLPGSQL;
 
+
+SELECT evergreen.upgrade_deps_block_check('1076', :eg_version); -- miker/gmcharlt
+
 CREATE OR REPLACE FUNCTION asset.cache_copy_visibility () RETURNS TRIGGER as $func$
 DECLARE
     ocn     asset.call_number%ROWTYPE;
@@ -1936,6 +1939,14 @@ BEGIN
                 UPDATE  biblio.record_entry
                   SET   vis_attr_vector = biblio.calculate_bib_visibility_attribute_set(ncn.record)
                   WHERE id = ocn.record;
+
+                -- We have to use a record-specific WHERE clause
+                -- to avoid modifying the entries for peer-bib copies.
+                UPDATE  asset.copy_vis_attr_cache
+                  SET   target_copy = NEW.id,
+                        record = ncn.record
+                  WHERE target_copy = OLD.id
+                        AND record = ocn.record;
             END IF;
         END IF;
 
@@ -1944,9 +1955,10 @@ BEGIN
            OLD.opac_visible <> NEW.opac_visible OR
            OLD.circ_lib     <> NEW.circ_lib
         THEN
-            -- any of these could change visibility, but
+            -- Any of these could change visibility, but
             -- we'll save some queries and not try to calculate
-            -- the change directly
+            -- the change directly.  We want to update peer-bib
+            -- entries in this case, unlike above.
             UPDATE  asset.copy_vis_attr_cache
               SET   target_copy = NEW.id,
                     vis_attr_vector = asset.calculate_copy_visibility_attribute_set(NEW.id)