Fixed update issues.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1578 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2005-11-07 16:02:16 +00:00
parent fa93bbcd37
commit 0258f04008
1 changed files with 5 additions and 3 deletions

View File

@ -308,7 +308,7 @@ if ( $version )
} }
} }
my $backup = ZM_DB_NAME."-".$version.".dump"; my $backup = ZM_DB_NAME."-".$version.".dump";
$command .= " ".ZM_DB_NAME." > ".$backup; $command .= " --add-drop-table --databases ".ZM_DB_NAME." > ".$backup;
print( "Creating backup to $backup. This may take several minutes.\n" ); print( "Creating backup to $backup. This may take several minutes.\n" );
print( "Executing '$command'\n" ) if ( VERBOSE ); print( "Executing '$command'\n" ) if ( VERBOSE );
my $output = qx($command); my $output = qx($command);
@ -374,6 +374,8 @@ if ( $version )
# Nothing yet # Nothing yet
} }
print( "\nUpgrading database to version ".ZM_VERSION."\n" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS );
my $cascade = undef; my $cascade = undef;
@ -493,7 +495,7 @@ if ( $version )
my $sequence = 1; my $sequence = 1;
while( my $monitor = $sth->fetchrow_hashref() ) while( my $monitor = $sth->fetchrow_hashref() )
{ {
my $sql = "update Monitors set Sequence = ? where MonitorId = ?"; my $sql = "update Monitors set Sequence = ? where Id = ?";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute( $sequence++, $monitor->{Id} ) or die( "Can't execute: ".$sth->errstr() ); my $res = $sth->execute( $sequence++, $monitor->{Id} ) or die( "Can't execute: ".$sth->errstr() );
} }
@ -503,7 +505,7 @@ if ( $version )
# Update saved filters # Update saved filters
{ {
print( "Updating saved filters. Please wait.\n" ); print( "Updating saved filters. Please wait.\n" );
my $sql = "select * from Filter"; my $sql = "select * from Filters";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() ); my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
my @filters; my @filters;