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:
parent
72d88cab9e
commit
0fdd8ca72e
1 changed files with 18 additions and 11 deletions
|
@ -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";
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue