From ce0708834564ce65af8427844d8d0aa27911f391 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 21 Jan 2026 09:36:15 +0000 Subject: [PATCH] Bug 26355: Add new columns to the patron categories and attributes tables Signed-off-by: Hannah Dunne-Howrie --- .../bug_26355-patron_self_renewal.pl | 78 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 6 ++ 2 files changed, 84 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_26355-patron_self_renewal.pl diff --git a/installer/data/mysql/atomicupdate/bug_26355-patron_self_renewal.pl b/installer/data/mysql/atomicupdate/bug_26355-patron_self_renewal.pl new file mode 100755 index 00000000000..50be96fbbc4 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_26355-patron_self_renewal.pl @@ -0,0 +1,78 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "26355", + description => "Patron self-renewal", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( column_exists( 'categories', 'self_renewal_enabled' ) ) { + $dbh->do( + q{ + ALTER TABLE categories ADD COLUMN `self_renewal_enabled` tinyint(1) NOT NULL DEFAULT 0 + COMMENT 'allow self renewal for this category' + AFTER `enforce_expiry_notice` + } + ); + + say_success( $out, "Added column 'self_renewal_enabled' to categories" ); + } + unless ( column_exists( 'categories', 'self_renewal_availability_start' ) ) { + $dbh->do( + q{ + ALTER TABLE categories ADD COLUMN `self_renewal_availability_start` smallint(6) DEFAULT NULL + COMMENT 'how long before the patron expiry date self-renewal should be made available (overrides system default of NotifyBorrowerDeparture)' + AFTER `self_renewal_enabled` + } + ); + + say_success( $out, "Added column 'self_renewal_availability_start' to categories" ); + } + unless ( column_exists( 'categories', 'self_renewal_fines_block' ) ) { + $dbh->do( + q{ + ALTER TABLE categories ADD COLUMN `self_renewal_fines_block` int(11) DEFAULT NULL + COMMENT 'the amount owed in fines before self renewal is blocked (overrides system default of noissuescharge)' + AFTER `self_renewal_availability_start` + } + ); + + say_success( $out, "Added column 'self_renewal_fines_block' to categories" ); + } + unless ( column_exists( 'categories', 'self_renewal_if_expired' ) ) { + $dbh->do( + q{ + ALTER TABLE categories ADD COLUMN `self_renewal_if_expired` smallint(6) DEFAULT 0 + COMMENT 'how long after expiry a patron can self renew their account' + AFTER `self_renewal_fines_block` + } + ); + + say_success( $out, "Added column 'self_renewal_if_expired' to categories" ); + } + unless ( column_exists( 'categories', 'self_renewal_failure_message' ) ) { + $dbh->do( + q{ + ALTER TABLE categories ADD COLUMN `self_renewal_failure_message` mediumtext DEFAULT NULL + COMMENT 'the message to display if self renewal is not successful' + AFTER `self_renewal_fines_block` + } + ); + + say_success( $out, "Added column 'self_renewal_failure_message' to categories" ); + } + unless ( column_exists( 'borrower_attribute_types', 'self_renewal_verification_check' ) ) { + $dbh->do( + q{ + ALTER TABLE borrower_attribute_types ADD COLUMN `self_renewal_verification_check` tinyint(1) NOT NULL DEFAULT 0 + COMMENT 'use this attribute as a verification step for patron self-renewal' + AFTER `opac_mandatory` + } + ); + + say_success( $out, "Added column 'self_renewal_verification_check' to borrower_attribute_types" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 733015e6e22..4341cb69a10 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1267,6 +1267,7 @@ CREATE TABLE `borrower_attribute_types` ( `keep_for_pseudonymization` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if this field is copied to anonymized_borrower_attributes (1 for yes, 0 for no)', `mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not in the staff interface', `opac_mandatory` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'defines if the attribute is mandatory or not in the OPAC', + `self_renewal_verification_check` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'use this attribute as a verification step for patron self-renewal', PRIMARY KEY (`code`), KEY `auth_val_cat_idx` (`authorised_value_category`), KEY `category_code` (`category_code`), @@ -1828,6 +1829,11 @@ CREATE TABLE `categories` ( `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', + `self_renewal_enabled` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'allow self renewal for this category', + `self_renewal_availability_start` smallint(6) DEFAULT NULL COMMENT 'how long before the patron expiry date self-renewal should be made available (overrides system default of NotifyBorrowerDeparture)', + `self_renewal_fines_block` int(11) DEFAULT NULL COMMENT 'the amount owed in fines before self renewal is blocked (overrides system default of noissuescharge)', + `self_renewal_if_expired` smallint(6) DEFAULT 0 COMMENT 'how long after expiry a patron can self renew their account', + `self_renewal_failure_message` mediumtext DEFAULT NULL COMMENT 'the message to display if self renewal is not successful', PRIMARY KEY (`categorycode`), UNIQUE KEY `categorycode` (`categorycode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.39.5