From 5bb7910ed6761b909062224f506d7aebccf85162 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Mon, 27 Feb 2017 09:41:55 +0000
Subject: [PATCH] Bug 18173: Remove DB field issues.return

The DB field issues.return has never really been used apparently.
I found the first occurrence of this field in
commit eac3a7b19a8aa7cda34aac396f5093c213a4aa5a
CommitDate: Mon Mar 12 22:43:47 2001 +0000
    Database definition file, checked into cvs to make keeping database
    current easier

Since I did not find any use of this field.
I guess it can be removed safely.

There is no proper test plan here. Just make sure this field has never
been used.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
I have not found any use of issues.return or old_issues.return. In
all my live instances the column is always NULL. Issuing and returning
seems to work as expected after the columns have been removed.
---
 installer/data/mysql/atomicupdate/bug_18173.perl | 13 +++++++++++++
 installer/data/mysql/kohastructure.sql           |  2 --
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 installer/data/mysql/atomicupdate/bug_18173.perl

diff --git a/installer/data/mysql/atomicupdate/bug_18173.perl b/installer/data/mysql/atomicupdate/bug_18173.perl
new file mode 100644
index 0000000..ea42d68
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_18173.perl
@@ -0,0 +1,13 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+    if ( column_exists( 'issues', 'return' ) ) {
+        $dbh->do(q|ALTER TABLE issues DROP column `return`|);
+    }
+
+    if ( column_exists( 'old_issues', 'return' ) ) {
+        $dbh->do(q|ALTER TABLE old_issues DROP column `return`|);
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 18173 - Remove issues.return DB field)\n";
+}
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 91e6119..e1704e5 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1741,7 +1741,6 @@ CREATE TABLE `issues` ( -- information related to check outs or issues
   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
   `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
   `lastreneweddate` datetime default NULL, -- date the item was last renewed
-  `return` varchar(4) default NULL,
   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
@@ -1770,7 +1769,6 @@ CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r
   `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
   `returndate` datetime default NULL, -- date the item was returned
   `lastreneweddate` datetime default NULL, -- date the item was last renewed
-  `return` varchar(4) default NULL,
   `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
   `auto_renew` BOOLEAN default FALSE, -- automatic renewal
   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
-- 
2.1.4