Bug 31086: Notify of problematic holds during upgrade

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 0704102bc8)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2022-07-22 12:31:55 +00:00 committed by Lucas Gass
parent 13a3b0be9c
commit 097969ac4d
1 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,5 @@
use Modern::Perl;
use Koha::Holds;
return {
bug_number => "31086",
@ -7,9 +8,17 @@ return {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
my $holds_no_branch = Koha::Holds->search({ branchcode => undef });
if( $holds_no_branch->count > 0 ){
say $out "Holds with no branchcode were found and will be updated to the first branch in the system";
while ( my $hnb = $holds_no_branch->next ){
say $out "Please review hold for borrowernumber " . $hnb->borrowernumber . " on biblionumber " . $hnb->biblionumber . " to correct pickup branch if necessary";
}
}
# Ensure we have no NULL's in the branchcode field
$dbh->do(q{
UPDATE reserves SET branchcode = ( SELECT branchcode FROM branches LIMIT 1) WHERE branchode IS NULL;
UPDATE reserves SET branchcode = ( SELECT branchcode FROM branches LIMIT 1) WHERE branchcode IS NULL;
});
# Set the NOT NULL configuration