Merge pull request #84 from knnniggett/patch-5

Update zmupdate.pl.in to give option to convert to InnoDB tables
pull/95/merge
Kyle Johnson 2013-08-30 18:47:34 -07:00
commit 52116f9642
1 changed files with 39 additions and 0 deletions

View File

@ -454,6 +454,35 @@ if ( $version )
}
}
sub toInnoDB
{
my $dbh = shift;
my $sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='zm' AND engine = 'MyISAM'";
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 @dbTables;
while( my $dbTable = $sth->fetchrow() )
{
push( @dbTables, $dbTable );
}
$sth->finish();
if (@dbTables)
{
print "\nConverting MyISAM tables to InnoDB. Please wait.\n";
foreach (@dbTables)
{
my $sql = "ALTER TABLE $_ ENGINE = InnoDB";
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() );
}
$sth->finish();
} else {
print "\nNo MyISAM tables found. Skipping...\n";
}
}
print( "\nUpgrading database to version ".ZM_VERSION."\n" );
# Update config first of all
@ -984,6 +1013,16 @@ if ( $version )
$dbh->do(q{alter table Monitors add column `Deinterlacing` INT unsigned NOT NULL default '0' after `Orientation`;});
} # end if
$sth->finish();
print( "\nPrevious versions of ZoneMinder used the MyISAM database engine.\nHowever, the recommended database engine is InnoDB.\n");
print( "\nHint: InnoDB tables are much less likely to be corrupted during an unclean shutdown.\n\nPress 'y' to convert your tables to InnoDB or 'n' to skip : ");
my $response = <STDIN>;
chomp( $response );
if ( $response =~ /^[yY]$/ )
{
toInnoDB($dbh);
}
$cascade = !undef;
}
if ( $cascade )