From 56b6504d59be62da618ad654e37faedb88f32242 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 9 Apr 2014 16:46:21 +0200 Subject: [PATCH] Extract schema creation code into its own method. --- core/command/db/converttype.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/command/db/converttype.php b/core/command/db/converttype.php index f406148ebd..170145940d 100644 --- a/core/command/db/converttype.php +++ b/core/command/db/converttype.php @@ -123,15 +123,7 @@ class ConvertType extends Command { $this->clearSchema($toDB->getSchemaManager(), $input, $output); } - $output->writeln('Creating schema in new database'); - $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('Creating schema in new database'); + $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(