Koha/installer/data/mysql/db_revs/231200061.pl
Martin Renvoize dc2388281c
Bug 36986L (follow-up) Ensure idempotency
MySQL/MariaDB checks the primary key/unique constraint before WHERE
clause when performing an UPDATE. As such, the lack of AutoLocation
existing will not prevent a failure on a second run of the update.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
2024-06-05 18:12:03 +01:00

31 lines
1,017 B
Perl
Executable file

use Modern::Perl;
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
return {
bug_number => "26176",
description => "Rename AutoLocation and StaffLoginBranchBasedOnIP system preferences",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
$dbh->do(
q{
UPDATE IGNORE systempreferences SET variable = "StaffLoginRestrictLibraryByIP"
WHERE variable = "AutoLocation"
}
) == 1
&& say_success( $out, "Renamed system preference 'AutoLocation' to 'StaffLoginRestrictLibraryByIP'" );
$dbh->do(
q{
UPDATE IGNORE systempreferences SET variable = "StaffLoginLibraryBasedOnIP"
WHERE variable = "StaffLoginBranchBasedOnIP"
}
) == 1
&& say_success(
$out,
"Renamed system preference 'StaffLoginBranchBasedOnIP' to 'StaffLoginLibraryBasedOnIP'"
);
},
};