Extract schema creation code into its own method.

This commit is contained in:
Andreas Fischer 2014-04-09 16:46:21 +02:00
parent 370593361b
commit 56b6504d59

View file

@ -123,15 +123,7 @@ class ConvertType extends Command {
$this->clearSchema($toDB->getSchemaManager(), $input, $output);
}
$output->writeln('<info>Creating schema in new database</info>');
$schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
$schemaManager->createDbFromStructure(\OC::$SERVERROOT.'/db_structure.xml');
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
foreach($apps as $app) {
if(file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
}
}
$this->createSchema($toDB, $input, $output);
$toTables = $this->getTables($toDB);
$fromTables = $this->getTables($fromDB);
@ -154,6 +146,18 @@ class ConvertType extends Command {
$this->convertDB($fromDB, $toDB, $tables, $input, $output);
}
protected function createSchema(Connection $toDB, InputInterface $input, OutputInterface $output) {
$output->writeln('<info>Creating schema in new database</info>');
$schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
$schemaManager->createDbFromStructure(\OC::$SERVERROOT.'/db_structure.xml');
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
foreach($apps as $app) {
if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
}
}
}
protected function getToDBConnection(InputInterface $input, OutputInterface $output) {
$type = $input->getArgument('type');
$connectionParams = array(