Stamping upgrade script
authorMike Rylander <mrylander@gmail.com>
Thu, 12 Jul 2018 13:39:36 +0000 (09:39 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 12 Jul 2018 13:39:36 +0000 (09:39 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1114.function.asset.copy_state-update.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.function.asset.copy_state-update.sql [deleted file]

index c71db97..5527d7d 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 ('1113', :eg_version); -- Dyrcona/csharp/miker
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1114', :eg_version); -- JBoyer/miker
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1114.function.asset.copy_state-update.sql b/Open-ILS/src/sql/Pg/upgrade/1114.function.asset.copy_state-update.sql
new file mode 100644 (file)
index 0000000..f288fd7
--- /dev/null
@@ -0,0 +1,44 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1114', :eg_version);
+
+CREATE OR REPLACE FUNCTION asset.copy_state (cid BIGINT) RETURNS TEXT AS $$
+DECLARE
+    last_circ_stop      TEXT;
+    the_copy        asset.copy%ROWTYPE;
+BEGIN
+
+    SELECT * INTO the_copy FROM asset.copy WHERE id = cid;
+    IF NOT FOUND THEN RETURN NULL; END IF;
+
+    IF the_copy.status = 3 THEN -- Lost
+        RETURN 'LOST';
+    ELSIF the_copy.status = 4 THEN -- Missing
+        RETURN 'MISSING';
+    ELSIF the_copy.status = 14 THEN -- Damaged
+        RETURN 'DAMAGED';
+    ELSIF the_copy.status = 17 THEN -- Lost and paid
+        RETURN 'LOST_AND_PAID';
+    END IF;
+
+    SELECT stop_fines INTO last_circ_stop
+      FROM  action.circulation
+      WHERE target_copy = cid AND checkin_time IS NULL
+      ORDER BY xact_start DESC LIMIT 1;
+
+    IF FOUND THEN
+        IF last_circ_stop IN (
+            'CLAIMSNEVERCHECKEDOUT',
+            'CLAIMSRETURNED',
+            'LONGOVERDUE'
+        ) THEN
+            RETURN last_circ_stop;
+        END IF;
+    END IF;
+
+    RETURN 'NORMAL';
+END;
+$$ LANGUAGE PLPGSQL;
+
+COMMIT;
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.asset.copy_state-update.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.asset.copy_state-update.sql
deleted file mode 100644 (file)
index 8ddf6cb..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-BEGIN;
-
-SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE FUNCTION asset.copy_state (cid BIGINT) RETURNS TEXT AS $$
-DECLARE
-    last_circ_stop      TEXT;
-    the_copy        asset.copy%ROWTYPE;
-BEGIN
-
-    SELECT * INTO the_copy FROM asset.copy WHERE id = cid;
-    IF NOT FOUND THEN RETURN NULL; END IF;
-
-    IF the_copy.status = 3 THEN -- Lost
-        RETURN 'LOST';
-    ELSIF the_copy.status = 4 THEN -- Missing
-        RETURN 'MISSING';
-    ELSIF the_copy.status = 14 THEN -- Damaged
-        RETURN 'DAMAGED';
-    ELSIF the_copy.status = 17 THEN -- Lost and paid
-        RETURN 'LOST_AND_PAID';
-    END IF;
-
-    SELECT stop_fines INTO last_circ_stop
-      FROM  action.circulation
-      WHERE target_copy = cid AND checkin_time IS NULL
-      ORDER BY xact_start DESC LIMIT 1;
-
-    IF FOUND THEN
-        IF last_circ_stop IN (
-            'CLAIMSNEVERCHECKEDOUT',
-            'CLAIMSRETURNED',
-            'LONGOVERDUE'
-        ) THEN
-            RETURN last_circ_stop;
-        END IF;
-    END IF;
-
-    RETURN 'NORMAL';
-END;
-$$ LANGUAGE PLPGSQL;
-
-COMMIT;
-