From 4d74135e6bd8841d5cc5693d4c03663adec4a061 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 2 Dec 2021 12:55:36 +0100
Subject: [PATCH] Bug 29605: branchtransfers.cancellation_reason

reason and cancellation_reason was inversed, and the enum values were
lower cases

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
---
 .../data/mysql/atomicupdate/bug_29605.pl      | 22 ++++++++++++++++
 installer/data/mysql/db_revs/210600003.pl     | 26 +++++++++----------
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/installer/data/mysql/atomicupdate/bug_29605.pl b/installer/data/mysql/atomicupdate/bug_29605.pl
index c1febb4717..3df37615d8 100755
--- a/installer/data/mysql/atomicupdate/bug_29605.pl
+++ b/installer/data/mysql/atomicupdate/bug_29605.pl
@@ -62,6 +62,28 @@ return {
         $dbh->do(q{ALTER TABLE search_marc_map MODIFY `marc_type` enum('marc21','unimarc') NOT NULL COMMENT 'what MARC type this map is for'});
         say $out "Ensure NOT NULL on search_marc_map.marc_type";
 
+        $dbh->do(
+            q{
+                alter table
+                    `branchtransfers`
+                modify column
+                    `cancellation_reason` enum(
+                        'Manual',
+                        'StockrotationAdvance',
+                        'StockrotationRepatriation',
+                        'ReturnToHome',
+                        'ReturnToHolding',
+                        'RotatingCollection',
+                        'Reserve',
+                        'LostReserve',
+                        'CancelReserve',
+                        'ItemLost',
+                        'WrongTransfer'
+                    ) DEFAULT NULL
+                after `reason`
+              }
+        );
+        say $out "Ensure branchtransfers.cancellation_reason enum values are uppercase";
     },
 
 }
diff --git a/installer/data/mysql/db_revs/210600003.pl b/installer/data/mysql/db_revs/210600003.pl
index edaa580737..e05228a3e8 100755
--- a/installer/data/mysql/db_revs/210600003.pl
+++ b/installer/data/mysql/db_revs/210600003.pl
@@ -14,19 +14,19 @@ use Modern::Perl;
                     `branchtransfers`
                 modify column
                     `cancellation_reason` enum(
-                        'manual',
-                        'stockrotationadvance',
-                        'stockrotationrepatriation',
-                        'returntohome',
-                        'returntoholding',
-                        'rotatingcollection',
-                        'reserve',
-                        'lostreserve',
-                        'cancelreserve',
-                        'itemlost',
-                        'wrongtransfer'
-                    )
-                after `comments`
+                        'Manual',
+                        'StockrotationAdvance',
+                        'StockrotationRepatriation',
+                        'ReturnToHome',
+                        'ReturnToHolding',
+                        'RotatingCollection',
+                        'Reserve',
+                        'LostReserve',
+                        'CancelReserve',
+                        'ItemLost',
+                        'WrongTransfer'
+                    ) DEFAULT NULL
+                after `reason`
               }
         );
     },
-- 
2.30.2