LP#1450561: Stamping upgrade script for library settings editor history limits
authorBen Shum <bshum@biblio.org>
Wed, 19 Aug 2015 02:22:42 +0000 (22:22 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 19 Aug 2015 02:22:42 +0000 (22:22 -0400)
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0925.limit_logs_oust-create.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.lmit_logs_oust-create.sql [deleted file]

index 71d46ae..93f283f 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 ('0924', :eg_version); -- dbwells/stomproj/bshum
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0925', :eg_version); -- dyrcona/bshum
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0925.limit_logs_oust-create.sql b/Open-ILS/src/sql/Pg/upgrade/0925.limit_logs_oust-create.sql
new file mode 100644 (file)
index 0000000..0343ca6
--- /dev/null
@@ -0,0 +1,26 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('0925', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.limit_oustl() RETURNS TRIGGER AS $oustl_limit$
+    BEGIN
+        -- Only keeps the most recent five settings changes.
+        DELETE FROM config.org_unit_setting_type_log WHERE field_name = NEW.field_name AND org = NEW.org AND date_applied NOT IN 
+        (SELECT date_applied FROM config.org_unit_setting_type_log WHERE field_name = NEW.field_name AND org = NEW.org ORDER BY date_applied DESC LIMIT 4);
+        
+        IF (TG_OP = 'UPDATE') THEN
+            RETURN NEW;
+        ELSIF (TG_OP = 'INSERT') THEN
+            RETURN NEW;
+        END IF;
+        RETURN NULL;
+    END;
+$oustl_limit$ LANGUAGE plpgsql;
+
+DROP TRIGGER IF EXISTS limit_logs_oust ON config.org_unit_setting_type_log;
+
+CREATE TRIGGER limit_logs_oust
+    BEFORE INSERT OR UPDATE ON config.org_unit_setting_type_log
+    FOR EACH ROW EXECUTE PROCEDURE limit_oustl();
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.lmit_logs_oust-create.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.lmit_logs_oust-create.sql
deleted file mode 100644 (file)
index e7cfb05..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-BEGIN;
-
---SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION evergreen.limit_oustl() RETURNS TRIGGER AS $oustl_limit$
-    BEGIN
-        -- Only keeps the most recent five settings changes.
-        DELETE FROM config.org_unit_setting_type_log WHERE field_name = NEW.field_name AND org = NEW.org AND date_applied NOT IN 
-        (SELECT date_applied FROM config.org_unit_setting_type_log WHERE field_name = NEW.field_name AND org = NEW.org ORDER BY date_applied DESC LIMIT 4);
-        
-        IF (TG_OP = 'UPDATE') THEN
-            RETURN NEW;
-        ELSIF (TG_OP = 'INSERT') THEN
-            RETURN NEW;
-        END IF;
-        RETURN NULL;
-    END;
-$oustl_limit$ LANGUAGE plpgsql;
-
-DROP TRIGGER IF EXISTS limit_logs_oust ON config.org_unit_setting_type_log;
-
-CREATE TRIGGER limit_logs_oust
-    BEFORE INSERT OR UPDATE ON config.org_unit_setting_type_log
-    FOR EACH ROW EXECUTE PROCEDURE limit_oustl();
-
-COMMIT;