From 6e7fdb8c0565fd0c8caf63128aa5d85088a03a24 Mon Sep 17 00:00:00 2001
From: Kyle M Hall <kyle@bywatersolutions.com>
Date: Mon, 18 May 2020 13:32:21 -0400
Subject: [PATCH] Bug 25534: Update database

---
 .../mysql/atomicupdate/cancellation_reason.perl  | 16 ++++++++++++++++
 installer/data/mysql/kohastructure.sql           |  2 ++
 2 files changed, 18 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/cancellation_reason.perl

diff --git a/installer/data/mysql/atomicupdate/cancellation_reason.perl b/installer/data/mysql/atomicupdate/cancellation_reason.perl
new file mode 100644
index 0000000000..cd73a1803b
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/cancellation_reason.perl
@@ -0,0 +1,16 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if ( CheckVersion( $DBversion ) ) {
+    if ( !column_exists( 'reserves', 'cancellation_reason' ) ) {
+        $dbh->do(q{
+            ALTER TABLE reserves ADD COLUMN `cancellation_reason` varchar(80) default NULL AFTER cancellationdate;
+        });
+    }
+
+    if ( !column_exists( 'old_reserves', 'cancellation_reason' ) ) {
+        $dbh->do(q{
+            ALTER TABLE old_reserves ADD COLUMN `cancellation_reason` varchar(80) default NULL AFTER cancellationdate;
+        });
+    }
+
+    NewVersion( $DBversion, 25534, "Add ability to send an email specifying a reason when canceling a hold");
+}
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index c5a3879662..4335d69895 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1752,6 +1752,7 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha
   `notificationdate` date default NULL, -- currently unused
   `reminderdate` date default NULL, -- currently unused
   `cancellationdate` date default NULL, -- the date this hold was cancelled
+  `cancellation_reason` varchar(80) default NULL, -- optional authorised value CANCELLATION_REASON
   `reservenotes` LONGTEXT, -- notes related to this hold
   `priority` smallint(6) NOT NULL DEFAULT 1, -- where in the queue the patron sits
   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
@@ -1792,6 +1793,7 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b
   `notificationdate` date default NULL, -- currently unused
   `reminderdate` date default NULL, -- currently unused
   `cancellationdate` date default NULL, -- the date this hold was cancelled
+  `cancellation_reason` varchar(80) default NULL, -- optional authorised value CANCELLATION_REASON
   `reservenotes` LONGTEXT, -- notes related to this hold
   `priority` smallint(6) NOT NULL DEFAULT 1, -- where in the queue the patron sits
   `found` varchar(1) default NULL, -- a one letter code defining what the status is of the hold is after it has been confirmed
-- 
2.24.2 (Apple Git-127)