revert to using the mysql client to do updates. We need it for delemiter changes when adding triggers
This commit is contained in:
parent
224e261ade
commit
796ba0d899
|
@ -932,17 +932,44 @@ sub patchDB {
|
|||
my $dbh = shift;
|
||||
my $version = shift;
|
||||
|
||||
my $file = ( $updateDir ? $updateDir : $Config{ZM_PATH_DATA}.'/db' ) . "/zm_update-$version.sql";
|
||||
my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
|
||||
my $command = 'mysql';
|
||||
if ( defined($portOrSocket) ) {
|
||||
if ( $portOrSocket =~ /^\// ) {
|
||||
$command .= ' -S'.$portOrSocket;
|
||||
} else {
|
||||
$command .= ' -h'.$host.' -P'.$portOrSocket;
|
||||
}
|
||||
} else {
|
||||
$command .= ' -h'.$host;
|
||||
}
|
||||
if ( $dbUser ) {
|
||||
$command .= ' -u'.$dbUser;
|
||||
$command .= ' -p"'.$dbPass.'"' if $dbPass;
|
||||
}
|
||||
$command .= ' '.$Config{ZM_DB_NAME}.' < ';
|
||||
if ( $updateDir ) {
|
||||
$command .= $updateDir;
|
||||
} else {
|
||||
$command .= $Config{ZM_PATH_DATA}.'/db';
|
||||
}
|
||||
$command .= '/zm_update-'.$version.'.sql';
|
||||
|
||||
open( my $fh, '<', $file ) or die "Unable to open $file $!";
|
||||
$/ = undef;
|
||||
my $sql = <$fh>;
|
||||
close $fh;
|
||||
$dbh->do($sql) or die $dbh->errstr();
|
||||
print( "Executing '$command'\n" ) if ( logDebugging() );
|
||||
my $output = qx($command);
|
||||
my $status = $? >> 8;
|
||||
if ( $status || logDebugging() ) {
|
||||
chomp( $output );
|
||||
print( "Output: $output\n" );
|
||||
}
|
||||
if ( $status ) {
|
||||
die( "Command '$command' exited with status: $status\n" );
|
||||
}
|
||||
print( "\nDatabase successfully upgraded to version $version.\n" );
|
||||
$sql = "update Config set Value = ? where Name = 'ZM_DYN_DB_VERSION'";
|
||||
my $sql = "update Config set Value = ? where Name = 'ZM_DYN_DB_VERSION'";
|
||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||
my $res = $sth->execute( $version ) or die( "Can't execute: ".$sth->errstr() );
|
||||
$sth->finish();
|
||||
}
|
||||
|
||||
sub migratePaths {
|
||||
|
|
Loading…
Reference in New Issue