From be98235195cccb6e0d7bb289753aa812bfde2d9e Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Wed, 22 Mar 2023 21:14:43 -1000 Subject: [PATCH] Bug 33300: [22.05.x] (follow-up) DBRev for existing databases Test plan : 1.1) Start from a Koha 22.05 1.2) Upgrade to master => Check the upgrade says : Wrong system preference 'AutomaticWrongTransfer' renamed 'AutomaticConfirmTransfer' 2.1) Start from a Koha 22.05 2.2) Upgrade to 22.11 2.3) Via interface change system preference 'AutomaticConfirmTransfer' and save 2.4) Upgrade to master => Check the upgrade says : Wrong system preference 'AutomaticWrongTransfer' deleted Signed-off-by: Katrin Fischer Signed-off-by: Marcel de Rooy --- .../data/mysql/atomicupdate/bug_33300.pl | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_33300.pl diff --git a/installer/data/mysql/atomicupdate/bug_33300.pl b/installer/data/mysql/atomicupdate/bug_33300.pl new file mode 100755 index 0000000000..01b36b2c61 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_33300.pl @@ -0,0 +1,32 @@ +use Modern::Perl; + +return { + bug_number => "33300", + description => "Fix missing wrong system preference 'AutomaticWrongTransfer'", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + my ($wrong_syspref_exists) = $dbh->selectrow_array(q{ + SELECT COUNT(*) FROM systempreferences WHERE variable='AutomaticWrongTransfer' + }); + if ($wrong_syspref_exists) { + # Correct preference may have been generated via interface + my ($correct_syspref_exists) = $dbh->selectrow_array(q{ + SELECT COUNT(*) FROM systempreferences WHERE variable='AutomaticConfirmTransfer' + }); + if ( $correct_syspref_exists ) { + $dbh->do(q{ + DELETE FROM systempreferences WHERE variable='AutomaticWrongTransfer' + }); + say $out "Wrong system preference 'AutomaticWrongTransfer' deleted"; + } else { + $dbh->do(q{ + UPDATE systempreferences SET variable='AutomaticConfirmTransfer' WHERE variable='AutomaticWrongTransfer' + }); + say $out "Wrong system preference 'AutomaticWrongTransfer' renamed 'AutomaticConfirmTransfer'"; + } + } else { + say $out "Wrong system preference 'AutomaticWrongTransfer' does not exist"; + } + }, +}; -- 2.40.1