Bug 25389: Catch errant cases of LOST_RETURNED
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 11 May 2020 10:39:00 +0000 (11:39 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 13 May 2020 09:36:20 +0000 (10:36 +0100)
For upgrades taking place after the fix for the update in bug 24592 was
pushed, we need to catch any last remaining error cases and correct
them.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

installer/data/mysql/atomicupdate/bug_25389.perl [new file with mode: 0644]

diff --git a/installer/data/mysql/atomicupdate/bug_25389.perl b/installer/data/mysql/atomicupdate/bug_25389.perl
new file mode 100644 (file)
index 0000000..722a4bf
--- /dev/null
@@ -0,0 +1,20 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+
+    # Migrate LOST_RETURNED to LOST_FOUND
+    $dbh->do(qq{
+        UPDATE
+          accountlines
+        SET
+          credit_type_code = 'LOST_FOUND'
+        WHERE
+          credit_type_code = 'LOST_RETURNED'
+    });
+
+    # Drop LOST_RETURNED credit type
+    $dbh->do(qq{
+        DELETE FROM account_credit_types WHERE code = 'LOST_RETURNED'
+    });
+
+    NewVersion( $DBversion, 25389, "Catch errant cases of LOST_RETURNED");
+}