LP#1117808: Stamping upgrade scripts for extend use of merge profiles
authorKathy Lussier <klussier@masslnc.org>
Fri, 17 Feb 2017 15:29:33 +0000 (10:29 -0500)
committerKathy Lussier <klussier@masslnc.org>
Fri, 17 Feb 2017 15:29:33 +0000 (10:29 -0500)
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1022.schema.more_overlay_funcs.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/1023.data.default_vmp_ou_settings.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.more_overlay_funcs.sql [deleted file]
Open-ILS/src/sql/Pg/upgrade/YYYY.data.default_vmp_ou_setting.sql [deleted file]

index 78bc5b9..f9c5ccc 100644 (file)
@@ -91,7 +91,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 ('1021', :eg_version); -- Jboyer/kmlussier
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1023', :eg_version); -- gmcharlt/kmlussier
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1022.schema.more_overlay_funcs.sql b/Open-ILS/src/sql/Pg/upgrade/1022.schema.more_overlay_funcs.sql
new file mode 100644 (file)
index 0000000..848e8a0
--- /dev/null
@@ -0,0 +1,59 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1022', :eg_version);
+
+CREATE OR REPLACE FUNCTION vandelay.merge_record_xml_using_profile ( incoming_marc TEXT, existing_marc TEXT, merge_profile_id BIGINT ) RETURNS TEXT AS $$
+DECLARE
+    merge_profile   vandelay.merge_profile%ROWTYPE;
+    dyn_profile     vandelay.compile_profile%ROWTYPE;
+    target_marc     TEXT;
+    source_marc     TEXT;
+    replace_rule    TEXT;
+    match_count     INT;
+BEGIN
+
+    IF existing_marc IS NULL OR incoming_marc IS NULL THEN
+        -- RAISE NOTICE 'no marc for source or target records';
+        RETURN NULL;
+    END IF;
+
+    IF merge_profile_id IS NOT NULL THEN
+        SELECT * INTO merge_profile FROM vandelay.merge_profile WHERE id = merge_profile_id;
+        IF FOUND THEN
+            dyn_profile.add_rule := COALESCE(merge_profile.add_spec,'');
+            dyn_profile.strip_rule := COALESCE(merge_profile.strip_spec,'');
+            dyn_profile.replace_rule := COALESCE(merge_profile.replace_spec,'');
+            dyn_profile.preserve_rule := COALESCE(merge_profile.preserve_spec,'');
+        ELSE
+            -- RAISE NOTICE 'merge profile not found';
+            RETURN NULL;
+        END IF;
+    ELSE
+        -- RAISE NOTICE 'no merge profile specified';
+        RETURN NULL;
+    END IF;
+
+    IF dyn_profile.replace_rule <> '' AND dyn_profile.preserve_rule <> '' THEN
+        -- RAISE NOTICE 'both replace [%] and preserve [%] specified', dyn_profile.replace_rule, dyn_profile.preserve_rule;
+        RETURN NULL;
+    END IF;
+
+    IF dyn_profile.replace_rule = '' AND dyn_profile.preserve_rule = '' AND dyn_profile.add_rule = '' AND dyn_profile.strip_rule = '' THEN
+        -- Since we have nothing to do, just return a target record as is
+        RETURN existing_marc;
+    ELSIF dyn_profile.preserve_rule <> '' THEN
+        source_marc = existing_marc;
+        target_marc = incoming_marc;
+        replace_rule = dyn_profile.preserve_rule;
+    ELSE
+        source_marc = incoming_marc;
+        target_marc = existing_marc;
+        replace_rule = dyn_profile.replace_rule;
+    END IF;
+
+    RETURN vandelay.merge_record_xml( target_marc, source_marc, dyn_profile.add_rule, replace_rule, dyn_profile.strip_rule );
+
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/1023.data.default_vmp_ou_settings.sql b/Open-ILS/src/sql/Pg/upgrade/1023.data.default_vmp_ou_settings.sql
new file mode 100644 (file)
index 0000000..4ea169e
--- /dev/null
@@ -0,0 +1,25 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1023', :eg_version);
+
+INSERT into config.org_unit_setting_type
+( name, grp, label, description, datatype, fm_class ) VALUES
+(
+    'cat.default_merge_profile', 'cat',
+    oils_i18n_gettext(
+        'cat.default_merge_profile',
+        'Default Merge Profile (Z39.50 and Record Buckets)',
+        'coust',
+        'label'
+    ),
+     oils_i18n_gettext(
+        'cat.default_merge_profile',
+        'Default merge profile to use during Z39.50 imports and record bucket merges',
+        'coust',
+        'description'
+    ),
+    'link',
+    'vmp'
+);
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.more_overlay_funcs.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.more_overlay_funcs.sql
deleted file mode 100644 (file)
index e3bfa2e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-BEGIN;
-
--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION vandelay.merge_record_xml_using_profile ( incoming_marc TEXT, existing_marc TEXT, merge_profile_id BIGINT ) RETURNS TEXT AS $$
-DECLARE
-    merge_profile   vandelay.merge_profile%ROWTYPE;
-    dyn_profile     vandelay.compile_profile%ROWTYPE;
-    target_marc     TEXT;
-    source_marc     TEXT;
-    replace_rule    TEXT;
-    match_count     INT;
-BEGIN
-
-    IF existing_marc IS NULL OR incoming_marc IS NULL THEN
-        -- RAISE NOTICE 'no marc for source or target records';
-        RETURN NULL;
-    END IF;
-
-    IF merge_profile_id IS NOT NULL THEN
-        SELECT * INTO merge_profile FROM vandelay.merge_profile WHERE id = merge_profile_id;
-        IF FOUND THEN
-            dyn_profile.add_rule := COALESCE(merge_profile.add_spec,'');
-            dyn_profile.strip_rule := COALESCE(merge_profile.strip_spec,'');
-            dyn_profile.replace_rule := COALESCE(merge_profile.replace_spec,'');
-            dyn_profile.preserve_rule := COALESCE(merge_profile.preserve_spec,'');
-        ELSE
-            -- RAISE NOTICE 'merge profile not found';
-            RETURN NULL;
-        END IF;
-    ELSE
-        -- RAISE NOTICE 'no merge profile specified';
-        RETURN NULL;
-    END IF;
-
-    IF dyn_profile.replace_rule <> '' AND dyn_profile.preserve_rule <> '' THEN
-        -- RAISE NOTICE 'both replace [%] and preserve [%] specified', dyn_profile.replace_rule, dyn_profile.preserve_rule;
-        RETURN NULL;
-    END IF;
-
-    IF dyn_profile.replace_rule = '' AND dyn_profile.preserve_rule = '' AND dyn_profile.add_rule = '' AND dyn_profile.strip_rule = '' THEN
-        -- Since we have nothing to do, just return a target record as is
-        RETURN existing_marc;
-    ELSIF dyn_profile.preserve_rule <> '' THEN
-        source_marc = existing_marc;
-        target_marc = incoming_marc;
-        replace_rule = dyn_profile.preserve_rule;
-    ELSE
-        source_marc = incoming_marc;
-        target_marc = existing_marc;
-        replace_rule = dyn_profile.replace_rule;
-    END IF;
-
-    RETURN vandelay.merge_record_xml( target_marc, source_marc, dyn_profile.add_rule, replace_rule, dyn_profile.strip_rule );
-
-END;
-$$ LANGUAGE PLPGSQL;
-
-COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/YYYY.data.default_vmp_ou_setting.sql b/Open-ILS/src/sql/Pg/upgrade/YYYY.data.default_vmp_ou_setting.sql
deleted file mode 100644 (file)
index ebc8b16..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-BEGIN;
-
--- SELECT evergreen.upgrade_deps_block_check('YYYY', :eg_version);
-
-INSERT into config.org_unit_setting_type
-( name, grp, label, description, datatype, fm_class ) VALUES
-(
-    'cat.default_merge_profile', 'cat',
-    oils_i18n_gettext(
-        'cat.default_merge_profile',
-        'Default Merge Profile (Z39.50 and Record Buckets)',
-        'coust',
-        'label'
-    ),
-     oils_i18n_gettext(
-        'cat.default_merge_profile',
-        'Default merge profile to use during Z39.50 imports and record bucket merges',
-        'coust',
-        'description'
-    ),
-    'link',
-    'vmp'
-);
-
-COMMIT;