From 4355f54f5ca00de9a32bd5c6c1c036657ca7a926 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 19 Sep 2024 11:40:24 +0000 Subject: [PATCH] Bug 37954: Atomic update Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../data/mysql/atomicupdate/bug_37954.pl | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_37954.pl diff --git a/installer/data/mysql/atomicupdate/bug_37954.pl b/installer/data/mysql/atomicupdate/bug_37954.pl new file mode 100755 index 0000000000..1c75e5b3ed --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37954.pl @@ -0,0 +1,44 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "37954", + description => "Move holdings_barcodes setting to holdings_barcode", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my ($existing_holdings_barcode_setting) = $dbh->selectrow_array( + q{ + SELECT COUNT(*) FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcode' + } + ); + if ($existing_holdings_barcode_setting) { + say_info( $out, "Settings already exist" ); + } else { + my ( $cannot_be_toggled, $is_hidden ) = $dbh->selectrow_array( + q{ + SELECT cannot_be_toggled,is_hidden FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcodes' + } + ); + + if ( defined $cannot_be_toggled || defined $is_hidden ) { + $dbh->do( + qq{ + INSERT IGNORE INTO columns_settings VALUES + ('catalogue', 'detail', 'holdings_table', 'holdings_barcode', $cannot_be_toggled, $is_hidden ) + } + ); + say_success( $out, "Settings moved to holdings_barcode" ); + } else { + say_info( $out, "No settings for holdings_barcodes found" ); + } + } + $dbh->do( + q{ + DELETE FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcodes' + } + ); + say $out "Removed settings for holdings_barcodes"; + }, +}; -- 2.39.5