Bug 7372: (follow-up) does execute this DB entry twice

Since this enh has been backported on 3.14, this patch should be applied
on 3.16 and master branch in order to update the updatedb entry.
It should not be executed twice otherwise the process is stuck on this
entry.

http://irc.koha-community.org/koha/2014-09-11#i_1567078

Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
Jonathan Druart 2014-09-11 15:22:44 +02:00 committed by Mason James
parent 73f4ace5da
commit 3ec80b6e6c
1 changed files with 25 additions and 20 deletions

View File

@ -7984,28 +7984,33 @@ if ( CheckVersion($DBversion) ) {
$dbh->{AutoCommit} = 0;
$dbh->{RaiseError} = 1;
my $av_added = $dbh->do(q|
INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
SELECT 'ROADTYPE', roadtypeid, road_type, road_type
FROM roadtype;
|);
my $rt_deleted = $dbh->do(q|
DELETE FROM roadtype
|);
if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
$dbh->do(q|
DROP TABLE roadtype;
eval {
$dbh->selectcol_arrayref(q|SELECT COUNT(*) FROM roadtype|);
};
unless ( $@ ) {
warn "pas erreur";
my $av_added = $dbh->do(q|
INSERT INTO authorised_values(category, authorised_value, lib, lib_opac)
SELECT 'ROADTYPE', roadtypeid, road_type, road_type
FROM roadtype;
|);
$dbh->commit;
print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
SetVersion($DBversion);
} else {
print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
$dbh->rollback;
}
my $rt_deleted = $dbh->do(q|
DELETE FROM roadtype
|);
if ( $av_added == $rt_deleted or $rt_deleted eq "0E0" ) {
$dbh->do(q|
DROP TABLE roadtype;
|);
$dbh->commit;
print "Upgrade to $DBversion done (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values)\n";
SetVersion($DBversion);
} else {
print "Upgrade to $DBversion failed (Bug 7372: Move road types from the roadtype table to the ROADTYPE authorised values.\nTransaction aborted because $@\n)";
$dbh->rollback;
}
}
$dbh->{AutoCommit} = 1;
$dbh->{RaiseError} = 0;
}