From e9fe7d00d69bdf404ebf48b679698cf5be101aef Mon Sep 17 00:00:00 2001
From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
Date: Tue, 3 Dec 2024 16:50:43 +0000
Subject: [PATCH] Bug 30301: Add a new column to enforce the expiry notice

Signed-off-by: Hanna Leiker <tech.hanna@salinapublic.org>
---
 ...30301-add_flag_to_enforce_expiry_notice.pl | 23 +++++++++++++++++++
 installer/data/mysql/kohastructure.sql        |  1 +
 2 files changed, 24 insertions(+)
 create mode 100755 installer/data/mysql/atomicupdate/bug_30301-add_flag_to_enforce_expiry_notice.pl

diff --git a/installer/data/mysql/atomicupdate/bug_30301-add_flag_to_enforce_expiry_notice.pl b/installer/data/mysql/atomicupdate/bug_30301-add_flag_to_enforce_expiry_notice.pl
new file mode 100755
index 00000000000..42fcd222de5
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_30301-add_flag_to_enforce_expiry_notice.pl
@@ -0,0 +1,23 @@
+use Modern::Perl;
+use Koha::Installer::Output qw(say_warning say_success say_info);
+
+return {
+    bug_number  => "30301",
+    description => "Add a flag to enforce expiry notices",
+    up          => sub {
+        my ($args) = @_;
+        my ( $dbh, $out ) = @$args{qw(dbh out)};
+
+        unless ( column_exists( 'categories', 'enforce_expiry_notice' ) ) {
+            $dbh->do(
+                q{
+                ALTER TABLE categories ADD COLUMN `enforce_expiry_notice` tinyint(1) NOT NULL DEFAULT 0
+                COMMENT "enforce the patron expiry notice for this category"
+                AFTER `noissueschargeguarantorswithguarantees`
+                }
+            );
+
+            say_success( $out, "Added column 'enforce_expiry_notice' to categories" );
+        }
+    },
+};
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 3602c65c18e..f722dfa24e7 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -1820,6 +1820,7 @@ CREATE TABLE `categories` (
   `noissuescharge` int(11) DEFAULT NULL COMMENT 'define maximum amount outstanding before checkouts are blocked',
   `noissueschargeguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount that the guarantees of a patron in this category can have outstanding before checkouts are blocked',
   `noissueschargeguarantorswithguarantees` int(11) DEFAULT NULL COMMENT 'define maximum amount that the guarantors with guarantees of a patron in this category can have outstanding before checkouts are blocked',
+  `enforce_expiry_notice` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'enforce the patron expiry notice for this category',
   PRIMARY KEY (`categorycode`),
   UNIQUE KEY `categorycode` (`categorycode`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- 
2.48.1