From 32d3edab19b555901e1622ea47da684e8a2fdff6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 19 Sep 2024 11:40:24 +0000 Subject: [PATCH] [23.11] Bug 37954: Atomic update --- .../data/mysql/atomicupdate/bug_37954.pl | 43 +++++++++++++++++++ 1 file changed, 43 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 00000000000..0a70872b9e7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37954.pl @@ -0,0 +1,43 @@ +use Modern::Perl; + +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 $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 $out "Settings moved to holdings_barcode"; + } else { + say $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