LP1910546: Stamping upgrade script
authorMichele Morgan <mmorgan@noblenet.org>
Mon, 1 Aug 2022 18:30:25 +0000 (14:30 -0400)
committerMichele Morgan <mmorgan@noblenet.org>
Mon, 1 Aug 2022 18:30:25 +0000 (14:30 -0400)
Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1328.schema.reject-active-acpl-deleted.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reject-active-acpl-delete.sql [deleted file]

index 89de0a6..626e611 100644 (file)
@@ -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 ('1327', :eg_version); -- berick/jamundson/mmorgan
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1328', :eg_version); -- berick/tlittle/mmorgan
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1328.schema.reject-active-acpl-deleted.sql b/Open-ILS/src/sql/Pg/upgrade/1328.schema.reject-active-acpl-deleted.sql
new file mode 100644 (file)
index 0000000..1df97e0
--- /dev/null
@@ -0,0 +1,30 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1328', :eg_version);
+
+CREATE OR REPLACE FUNCTION asset.check_delete_copy_location(acpl_id INTEGER)
+    RETURNS VOID AS $FUNK$
+BEGIN
+    PERFORM TRUE FROM asset.copy WHERE location = acpl_id AND NOT deleted LIMIT 1;
+
+    IF FOUND THEN
+        RAISE EXCEPTION
+            'Copy location % contains active copies and cannot be deleted', acpl_id;
+    END IF;
+END;
+$FUNK$ LANGUAGE plpgsql;
+
+DROP RULE protect_copy_location_delete ON asset.copy_location;
+
+CREATE RULE protect_copy_location_delete AS
+    ON DELETE TO asset.copy_location DO INSTEAD (
+        SELECT asset.check_delete_copy_location(OLD.id);
+        UPDATE asset.copy_location SET deleted = TRUE WHERE OLD.id = asset.copy_location.id;
+        UPDATE acq.lineitem_detail SET location = NULL WHERE location = OLD.id;
+        DELETE FROM asset.copy_location_order WHERE location = OLD.id;
+        DELETE FROM asset.copy_location_group_map WHERE location = OLD.id;
+        DELETE FROM config.circ_limit_set_copy_loc_map WHERE copy_loc = OLD.id;
+    );
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reject-active-acpl-delete.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reject-active-acpl-delete.sql
deleted file mode 100644 (file)
index b767ba8..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-BEGIN;
-
--- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
-
-CREATE OR REPLACE FUNCTION asset.check_delete_copy_location(acpl_id INTEGER)
-    RETURNS VOID AS $FUNK$
-BEGIN
-    PERFORM TRUE FROM asset.copy WHERE location = acpl_id AND NOT deleted LIMIT 1;
-
-    IF FOUND THEN
-        RAISE EXCEPTION
-            'Copy location % contains active copies and cannot be deleted', acpl_id;
-    END IF;
-END;
-$FUNK$ LANGUAGE plpgsql;
-
-DROP RULE protect_copy_location_delete ON asset.copy_location;
-
-CREATE RULE protect_copy_location_delete AS
-    ON DELETE TO asset.copy_location DO INSTEAD (
-        SELECT asset.check_delete_copy_location(OLD.id);
-        UPDATE asset.copy_location SET deleted = TRUE WHERE OLD.id = asset.copy_location.id;
-        UPDATE acq.lineitem_detail SET location = NULL WHERE location = OLD.id;
-        DELETE FROM asset.copy_location_order WHERE location = OLD.id;
-        DELETE FROM asset.copy_location_group_map WHERE location = OLD.id;
-        DELETE FROM config.circ_limit_set_copy_loc_map WHERE copy_loc = OLD.id;
-    );
-
-COMMIT;
-