From 4bff42d139bfe7435523562c9d736ce1c59f05bf Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Thu, 21 May 2020 23:19:23 +0000
Subject: [PATCH] Bug 25560: Database and installer changes

-- Adds boolean flag itemtypes.updatenotforloanstatusoncheckin

Sponsored-By: Waikato Institute of Technology, NZ
---
 .../bug_25560-add_boolean_updatenotforloanstatusoncheckin.perl   | 9 +++++++++
 installer/data/mysql/kohastructure.sql                           | 1 +
 2 files changed, 10 insertions(+)
 create mode 100644 installer/data/mysql/atomicupdate/bug_25560-add_boolean_updatenotforloanstatusoncheckin.perl

diff --git a/installer/data/mysql/atomicupdate/bug_25560-add_boolean_updatenotforloanstatusoncheckin.perl b/installer/data/mysql/atomicupdate/bug_25560-add_boolean_updatenotforloanstatusoncheckin.perl
new file mode 100644
index 0000000000..eb625029bd
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_25560-add_boolean_updatenotforloanstatusoncheckin.perl
@@ -0,0 +1,9 @@
+$DBversion = 'XXX';
+if( CheckVersion( $DBversion ) ) {
+
+    if( !column_exists( 'itemtypes', 'updatenotforloanstatusoncheckin' ) ) {
+        $dbh->do(q{ ALTER TABLE itemtypes ADD COLUMN updatenotforloanstatusoncheckin TINYINT(1) NOT NULL DEFAULT 0 AFTER hideinopac });
+    }
+
+    NewVersion( $DBversion, 25560, "Add updatenotforloanstatusoncheckin boolean flag to itemtypestable");
+}
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index c5a3879662..275a30b375 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -907,6 +907,7 @@ CREATE TABLE `itemtypes` ( -- defines the item types
   checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message"
   sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype
   hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
+  updatenotforloanstatusoncheckin tinyint(1) NOT NULL DEFAULT 0, -- Enable the itemtype to be altered by the UpdateNotForLoanStatusOnCheckin system preference
   searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
   PRIMARY KEY  (`itemtype`),
   UNIQUE KEY `itemtype` (`itemtype`)
-- 
2.11.0