Bug 33297: (follow-up) DBRev check wrong preference exists

Better db upgrade messages

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Fridolin Somers 2023-03-22 21:09:35 -10:00 committed by Tomas Cohen Arazi
parent 72d88cab9e
commit 0fdd8ca72e
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -6,20 +6,27 @@ return {
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'
my ($wrong_syspref_exists) = $dbh->selectrow_array(q{
SELECT COUNT(*) FROM systempreferences WHERE variable='RetainPatronSearchTerms'
});
if ($correct_syspref_exists) {
$dbh->do(q{
DELETE FROM systempreferences WHERE variable='RetainPatronSearchTerms'
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='RetainPatronsSearchTerms'
});
say $out "Wrong system preference 'RetainPatronSearchTerms' deleted";
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'";
}
} else {
$dbh->do(q{
UPDATE systempreferences SET variable='RetainPatronsSearchTerms' WHERE variable='RetainPatronSearchTerms'
});
say $out "Wrong system preference 'RetainPatronSearchTerms' renamed 'RetainPatronsSearchTerms'";
say $out "Wrong system preference 'RetainPatronSearchTerms' does not exist";
}
},
};