Bug 33297: (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 'RetainPatronSearchTerms' renamed 'RetainPatronsSearchTerms'
2.1) Start from a Koha 22.05
2.2) Upgrade to 22.11
2.3) Via interface change system preference 'RetainPatronsSearchTerms' and save
2.4) Upgrade to master
=> Check the upgrade says :
   Wrong system preference 'RetainPatronSearchTerms' deleted

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 72d88cab9e)
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
This commit is contained in:
Fridolin Somers 2023-03-21 22:30:21 -10:00 committed by Pedro Amorim
parent 247f2e23de
commit f45c85e8e0

View file

@ -0,0 +1,25 @@
use Modern::Perl;
return {
bug_number => "33297",
description => "Fix missing 's' in system preference 'RetainPatronSearchTerms'",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
# Correct preference may have been generated via interface
my ($correct_syspref_exists) = $dbh->selectrow_array(q{
SELECT COUNT(*) FROM systempreferences WHERE variable='RetainPatronsSearchTerms'
});
if ($correct_syspref_exists) {
$dbh->do(q{
DELETE FROM systempreferences WHERE variable='RetainPatronSearchTerms'
});
say $out "Wrong system preference 'RetainPatronSearchTerms' deleted";
} else {
$dbh->do(q{
UPDATE systempreferences SET variable='RetainPatronsSearchTerms' WHERE variable='RetainPatronSearchTerms'
});
say $out "Wrong system preference 'RetainPatronSearchTerms' renamed 'RetainPatronsSearchTerms'";
}
},
};