fixed version compare logic
This commit is contained in:
parent
b74abe88c9
commit
e0e048fe7e
|
@ -50,6 +50,7 @@ configuring upgrades etc, including on the fly upgrades.
|
|||
=cut
|
||||
use strict;
|
||||
use bytes;
|
||||
use version;
|
||||
|
||||
# ==========================================================================
|
||||
#
|
||||
|
@ -1027,16 +1028,23 @@ if ( $version )
|
|||
my @files;
|
||||
$updateDir = $Config{ZM_PATH_DATA}."/db" if ! $updateDir;
|
||||
opendir( my $dh, $updateDir ) || die "Can't open updateDir $!";
|
||||
@files = sort grep { (!/^\./) && /^zm_update\-[\d\.]+\.sql$/ && -f "$updateDir/$_" } readdir($dh);
|
||||
#@files = sort grep { (!/^\./) && /^zm_update\-[\d\.]+\.sql$/ && -f "$updateDir/$_" } readdir($dh);
|
||||
#PP - use perl version sort
|
||||
@files = sort {
|
||||
my ($x) = ($a =~ m/^zm_update\-(.*)\.sql$/);
|
||||
my ($y) = ($b =~ m/^zm_update\-(.*)\.sql$/);
|
||||
version->parse($x) <=> version->parse($y)
|
||||
} grep { (!/^\./) && /^zm_update\-[\d\.]+\.sql$/ && -f "$updateDir/$_" } readdir($dh);
|
||||
closedir $dh;
|
||||
if ( ! @files ) {
|
||||
die "Should have found upgrade scripts at $updateDir\n";
|
||||
} # end if
|
||||
if ( ! @files ) {
|
||||
die "Should have found upgrade scripts at $updateDir\n";
|
||||
} # end if
|
||||
|
||||
$dbh->{'AutoCommit'} = 0;
|
||||
foreach my $patch ( @files ) {
|
||||
my ( $v ) = $patch =~ /^zm_update\-([\d\.]+)\.sql$/;
|
||||
if ( $v ge $version ) {
|
||||
#PP make sure we use version compare
|
||||
if ( version->parse($v) ge version->parse($version) ) {
|
||||
print( "Upgrading DB to $v from $version\n" );
|
||||
patchDB( $dbh, $v );
|
||||
if ( $dbh->errstr() ) {
|
||||
|
|
Loading…
Reference in New Issue