From 87e86d3097bf23f58cd69c425f68abb374d02088 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Fri, 11 Apr 2025 20:41:17 +0000 Subject: [PATCH] Bug 39618: Add index to borrowers.preferred_name column To test: 1. APPLY PATCH 2. updatedatabase --- .../bug_39618_add_preferred_name_key.pl | 21 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 22 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_39618_add_preferred_name_key.pl diff --git a/installer/data/mysql/atomicupdate/bug_39618_add_preferred_name_key.pl b/installer/data/mysql/atomicupdate/bug_39618_add_preferred_name_key.pl new file mode 100755 index 00000000000..f0fc844dcd6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39618_add_preferred_name_key.pl @@ -0,0 +1,21 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "39618", + description => "Add index to borrowers.preferred_name", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( index_exists( 'borrowers', 'preferred_name_idx' ) ) { + $dbh->do( + q{ + ALTER TABLE `borrowers` + ADD KEY `preferred_name_idx` (`preferred_name`) + } + ); + say_success( $out, "Added index to borrowers.preferred_name" ); + } + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index fe7d54cf2df..8078b6cee89 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1620,6 +1620,7 @@ CREATE TABLE `borrowers` ( KEY `cardnumber_idx` (`cardnumber`), KEY `userid_idx` (`userid`), KEY `middle_name_idx` (`middle_name`(768)), + KEY `preferred_name_idx` (`preferred_name`), CONSTRAINT `borrowers_ibfk_1` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`), CONSTRAINT `borrowers_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`), CONSTRAINT `borrowers_ibfk_3` FOREIGN KEY (`sms_provider_id`) REFERENCES `sms_providers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE -- 2.39.5