Move schema clearing to extra method.

This commit is contained in:
Andreas Fischer 2014-04-09 15:45:30 +02:00
parent 3e0858e51f
commit 03a3f66867
1 changed files with 13 additions and 8 deletions

View File

@ -9,6 +9,8 @@
namespace OC\Core\Command\Db;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use OC\Config;
use OC\DB\Connection;
use OC\DB\ConnectionFactory;
@ -104,14 +106,7 @@ class ConvertType extends Command {
$toDB = $this->getToDBConnection($input, $output);
if ($input->getOption('clear-schema')) {
$schemaManager = $toDB->getSchemaManager();
$toTables = $schemaManager->listTableNames();
if (!empty($toTables)) {
$output->writeln('<info>Clearing schema in new database</info>');
}
foreach($toTables as $table) {
$schemaManager->dropTable($table);
}
$this->clearSchema($toDB->getSchemaManager(), $input, $output);
}
$output->writeln('<info>Creating schema in new database</info>');
@ -160,6 +155,16 @@ class ConvertType extends Command {
return $this->connectionFactory->getConnection($type, $connectionParams);
}
protected function clearSchema(AbstractSchemaManager $schemaManager, InputInterface $input, OutputInterface $output) {
$toTables = $schemaManager->listTableNames();
if (!empty($toTables)) {
$output->writeln('<info>Clearing schema in new database</info>');
}
foreach($toTables as $table) {
$schemaManager->dropTable($table);
}
}
protected function getTables(Connection $db) {
$schemaManager = $db->getSchemaManager();
return $schemaManager->listTableNames();