6 description => "Do not allow null values in branchcodes for reserves",
9 my ($dbh, $out) = @$args{qw(dbh out)};
11 my $holds_no_branch = Koha::Holds->search({ branchcode => undef });
12 if( $holds_no_branch->count > 0 ){
13 say $out "Holds with no branchcode were found and will be updated to the first branch in the system";
14 while ( my $hnb = $holds_no_branch->next ){
15 say $out "Please review hold for borrowernumber " . $hnb->borrowernumber . " on biblionumber " . $hnb->biblionumber . " to correct pickup branch if necessary";
19 # Ensure we have no NULL's in the branchcode field
21 UPDATE reserves SET branchcode = ( SELECT branchcode FROM branches LIMIT 1) WHERE branchcode IS NULL;
24 # Set the NOT NULL configuration
27 MODIFY COLUMN `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'foreign key from the branches table defining which branch the patron wishes to pick this hold up at'
30 # Print useful stuff here
31 say $out "Removed NULL option from branchcode for reserves";