From 0704102bc800dd43db1255918348e454a6df2f75 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 22 Jul 2022 12:31:55 +0000 Subject: [PATCH] Bug 31086: Notify of problematic holds during upgrade Signed-off-by: Tomas Cohen Arazi --- ..._31086_do_not_allow_null_branchcode_in_reserves.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl index ea2c1a6eb4..4e9c88c4ba 100755 --- a/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl +++ b/installer/data/mysql/atomicupdate/bug_31086_do_not_allow_null_branchcode_in_reserves.pl @@ -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 -- 2.39.5