Bugzilla – Attachment 186691 Details for
Bug 3492
Move hold fee setting into circulation rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 3492: Database migration for hold fees to circulation rules
Bug-3492-Database-migration-for-hold-fees-to-circu.patch (text/plain), 5.51 KB, created by
Martin Renvoize (ashimema)
on 2025-09-22 13:44:46 UTC
(
hide
)
Description:
Bug 3492: Database migration for hold fees to circulation rules
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-09-22 13:44:46 UTC
Size:
5.51 KB
patch
obsolete
>From f901d58f5b9e27c5321f5a2288727aaf0ba9154d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Mon, 8 Sep 2025 18:43:44 +0100 >Subject: [PATCH] Bug 3492: Database migration for hold fees to circulation > rules > >This commit adds the database migration to move hold fee configuration >from patron categories to circulation rules, providing more granular >control over hold fees based on patron category, item type, and branch. > >The migration: >- Creates circulation rules for existing categories.reservefee values >- Removes the deprecated reservefee column from categories table > >Sponsored-by: OpenFifth <https://openfifth.co.uk> >Signed-off-by: Jackie Usher <jackie.usher@westsussex.gov.uk> >--- > installer/data/mysql/atomicupdate/bug_3492.pl | 79 +++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 1 - > 2 files changed, 79 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_3492.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_3492.pl b/installer/data/mysql/atomicupdate/bug_3492.pl >new file mode 100644 >index 00000000000..f3ff016cb42 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_3492.pl >@@ -0,0 +1,79 @@ >+use Modern::Perl; >+use Koha::Installer::Output qw(say_warning say_failure say_success say_info); >+ >+return { >+ bug_number => "3492", >+ description => "Migrate reservefee from categories to circulation rules and remove deprecated column", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Check if the reservefee column still exists >+ my $column_exists = $dbh->selectrow_array( >+ q{ >+ SELECT COUNT(*) >+ FROM INFORMATION_SCHEMA.COLUMNS >+ WHERE TABLE_SCHEMA = DATABASE() >+ AND TABLE_NAME = 'categories' >+ AND COLUMN_NAME = 'reservefee' >+ } >+ ); >+ >+ if ($column_exists) { >+ >+ # Check if we have any existing reservefees to migrate >+ my $existing_fees = $dbh->selectall_arrayref( >+ q{ >+ SELECT categorycode, reservefee >+ FROM categories >+ WHERE reservefee IS NOT NULL AND reservefee > 0 >+ }, { Slice => {} } >+ ); >+ >+ if (@$existing_fees) { >+ say_info( >+ $out, >+ "Migrating " >+ . scalar(@$existing_fees) >+ . " existing hold fees from categories to circulation rules..." >+ ); >+ >+ # Migrate existing reservefee values to circulation_rules >+ my $insert_rule = $dbh->prepare( >+ q{ >+ INSERT IGNORE INTO circulation_rules >+ (branchcode, categorycode, itemtype, rule_name, rule_value) >+ VALUES (NULL, ?, NULL, 'hold_fee', ?) >+ } >+ ); >+ >+ my $migrated = 0; >+ for my $fee (@$existing_fees) { >+ $insert_rule->execute( $fee->{categorycode}, $fee->{reservefee} ); >+ if ( $insert_rule->rows ) { >+ $migrated++; >+ } >+ } >+ >+ say_success( $out, "Successfully migrated $migrated hold fee rules to circulation_rules table." ); >+ >+ if ( $migrated < @$existing_fees ) { >+ say_warning( $out, "Some rules may have already existed and were not overwritten." ); >+ } >+ } else { >+ say_info( $out, "No existing hold fees found in categories table to migrate." ); >+ } >+ >+ # Remove the deprecated reservefee column >+ say_info( $out, "Removing deprecated reservefee column from categories table..." ); >+ $dbh->do(q{ALTER TABLE categories DROP COLUMN reservefee}); >+ say_success( $out, "Successfully removed reservefee column from categories table." ); >+ >+ } else { >+ say_info( $out, "The reservefee column has already been removed from the categories table." ); >+ } >+ >+ say_info( $out, "Hold fees can now be configured in Administration > Circulation and fine rules." ); >+ say_success( $out, "Migration complete: Hold fees are now fully managed through circulation rules." ); >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 948683dc43b..b6e810a6ece 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1803,7 +1803,6 @@ CREATE TABLE `categories` ( > `dateofbirthrequired` tinyint(1) DEFAULT NULL COMMENT 'the minimum age required for the patron category', > `enrolmentfee` decimal(28,6) DEFAULT NULL COMMENT 'enrollment fee for the patron', > `overduenoticerequired` tinyint(1) DEFAULT NULL COMMENT 'are overdue notices sent to this patron category (1 for yes, 0 for no)', >- `reservefee` decimal(28,6) DEFAULT NULL COMMENT 'cost to place holds', > `hidelostitems` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'are lost items shown to this category (1 for yes, 0 for no)', > `category_type` varchar(1) NOT NULL DEFAULT 'A' COMMENT 'type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)', > `BlockExpiredPatronOpacActions` varchar(128) NOT NULL DEFAULT 'follow_syspref_BlockExpiredPatronOpacActions' COMMENT 'specific actions expired patrons of this category are blocked from performing or if the BlockExpiredPatronOpacActions system preference is to be followed', >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3492
:
1356
|
1357
|
119909
|
186336
|
186337
|
186338
|
186339
|
186340
|
186361
|
186691
|
186692
|
186693
|
186694
|
186695
|
186696
|
186711
|
186712
|
186713
|
186714
|
186715
|
186716