Bug 33489: Add indices to default patron search fields

This patch adds indices to the borrowers table to match the default
search fields for patrons.

To test:
1 - Apply patch
2 - Update database
3 - Ensure patron searching works as before

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-04-11 17:33:55 +00:00 committed by Tomas Cohen Arazi
parent 62f176d079
commit 1faf3bcf2a
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,23 @@
use Modern::Perl;
return {
bug_number => "33489",
description => "Add indices to default patron search fields",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
# Do you stuffs here
unless ( index_exists( 'borrowers', 'cardnumber_idx' ) ) {
$dbh->do(q{CREATE INDEX cardnumber_idx ON borrowers ( cardnumber )});
say $out "Added new index on borrowers.cardnumber";
}
unless ( index_exists( 'borrowers', 'userid_idx' ) ) {
$dbh->do(q{CREATE INDEX userid_idx ON borrowers ( userid )});
say $out "Added new index on borrowers.userid";
}
unless ( index_exists( 'borrowers', 'middle_name_idx' ) ) {
$dbh->do(q{CREATE INDEX middle_name_idx ON borrowers ( middle_name )});
say $out "Added new index on borrowers.midddle_name";
}
},
};

View File

@ -1527,6 +1527,9 @@ CREATE TABLE `borrowers` (
KEY `firstname_idx` (`firstname`(191)),
KEY `othernames_idx` (`othernames`(191)),
KEY `sms_provider_id` (`sms_provider_id`),
KEY `cardnumber_idx` (`cardnumber`),
KEY `userid_idx` (`userid`),
KEY `middle_name_idx` (`middle_name`(768)),
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