Use migrations on convert

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-07-19 11:48:58 +02:00
parent 9307aaee49
commit 1d56b52761
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 8 additions and 1 deletions

View File

@ -28,6 +28,7 @@
namespace OC\Core\Command\Db;
use OC\DB\MigrationService;
use OCP\DB\QueryBuilder\IQueryBuilder;
use \OCP\IConfig;
use OC\DB\Connection;
@ -219,12 +220,18 @@ class ConvertType extends Command implements CompletionAwareInterface {
protected function createSchema(Connection $toDB, InputInterface $input, OutputInterface $output) {
$output->writeln('<info>Creating schema in new database</info>');
$ms = new MigrationService('core', $toDB);
$ms->migrate(); // FIXME should only migrate to the current version?
$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');
} else {
$ms = new MigrationService($app, $toDB);
$ms->migrate(); // FIXME should only migrate to the current version?
}
}
}