Bug 42988: Update database, set holds_get_captured default to 1

The migration from SIPconfig.xml to the database ( bug 37893 ) leaves
holds_get_captured NULL for any account that didn't define it in the
config file. At SIP checkin an unset holds_get_captured defaults to
on, but the REST API returns NULL boolean columns as false, so the
SIP account editor shows "No" selected. Saving the account without
touching the option then stores 0 and holds are no longer captured
at SIP checkin.

This patch changes the column default to 1 and sets existing NULL
values to 1 so the stored value matches the actual checkin behavior.

Test Plan:
1) If you have no SIP accounts, create one
2) Simulate an account migrated from a SIPconfig.xml that doesn't define holds_get_captured:
   UPDATE sip_accounts SET holds_get_captured = NULL;
3) Edit the account, note "Holds get captured" shows "No" even though
   holds *are* captured at SIP checkin while the value is unset
4) Apply this patch
5) Run updatedatabase.pl
6) SELECT login_id, holds_get_captured FROM sip_accounts;
7) Note holds_get_captured is now 1!
8) Edit the account again, note "Yes" is now selected for "Holds get captured"!

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Kyle M Hall 2026-07-02 13:00:39 -04:00 committed by Lucas Gass
parent c6af8b9768
commit 5f4fc10df5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 29 additions and 1 deletions

View File

@ -0,0 +1,28 @@
use Modern::Perl;
use Koha::Installer::Output qw(say_success say_failure);
return {
bug_number => "42988",
description => "Set holds_get_captured default to 1 in sip_accounts",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
my $updated = $dbh->do(q{UPDATE sip_accounts SET holds_get_captured = 1 WHERE holds_get_captured IS NULL});
if ($updated) {
say_success(
$out,
"Set holds_get_captured to 1 for " . ( $updated + 0 ) . " sip_accounts rows where it was NULL"
);
} else {
say_failure( $out, "Failed to update NULL holds_get_captured rows in sip_accounts: " . $dbh->errstr );
}
my $altered = $dbh->do(q{ALTER TABLE sip_accounts ALTER COLUMN holds_get_captured SET DEFAULT 1});
if ($altered) {
say_success( $out, "Changed default of 'holds_get_captured' in sip_accounts to 1" );
} else {
say_failure( $out, "Failed to change default of 'holds_get_captured' in sip_accounts: " . $dbh->errstr );
}
},
};

View File

@ -6313,7 +6313,7 @@ CREATE TABLE `sip_accounts` (
`format_due_date` tinyint(1) DEFAULT NULL,
`hide_fields` varchar(255) DEFAULT NULL,
`holds_block_checkin` tinyint(1) DEFAULT NULL,
`holds_get_captured` tinyint(1) DEFAULT NULL,
`holds_get_captured` tinyint(1) DEFAULT 1,
`inhouse_item_types` varchar(255) DEFAULT NULL,
`inhouse_patron_categories` varchar(255) DEFAULT NULL,
`login_id` varchar(255) NOT NULL COMMENT 'Staff userid for SIP2 authentication',