Move schema clearing to extra method.
This commit is contained in:
parent
3e0858e51f
commit
03a3f66867
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue