Bye bye database.xml

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-06-30 21:47:31 +02:00 committed by Morris Jobke
parent 6e40c2fb52
commit bb0c50717c
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
3 changed files with 25 additions and 42 deletions

View File

@ -247,17 +247,13 @@ class ConvertType extends Command implements CompletionAwareInterface {
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
foreach ($apps as $app) {
$output->writeln('<info> - '.$app.'</info>');
if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
} else {
// Make sure autoloading works...
\OC_App::loadApp($app);
$fromMS = new MigrationService($app, $fromDB);
$currentMigration = $fromMS->getMigration('current');
if ($currentMigration !== '0') {
$toMS = new MigrationService($app, $toDB);
$toMS->migrate($currentMigration, true);
}
// Make sure autoloading works...
\OC_App::loadApp($app);
$fromMS = new MigrationService($app, $fromDB);
$currentMigration = $fromMS->getMigration('current');
if ($currentMigration !== '0') {
$toMS = new MigrationService($app, $toDB);
$toMS->migrate($currentMigration, true);
}
}
}

View File

@ -46,8 +46,8 @@ use OC\App\AppStore\Fetcher\AppFetcher;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Archive\TAR;
use OC\DB\Connection;
use OC\DB\MigrationService;
use OC_App;
use OC_DB;
use OC_Helper;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
@ -114,6 +114,11 @@ class Installer {
}
$basedir = $app['path'].'/'.$appId;
if (is_file($basedir . '/appinfo/database.xml')) {
throw new \Exception('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
}
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);
$l = \OC::$server->getL10N('core');
@ -152,16 +157,9 @@ class Installer {
}
//install the database
if (is_file($basedir.'/appinfo/database.xml')) {
if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) {
OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
} else {
OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml');
}
} else {
$ms = new \OC\DB\MigrationService($info['id'], \OC::$server->get(Connection::class));
$ms->migrate('latest', true);
}
$ms = new MigrationService($info['id'], \OC::$server->get(Connection::class));
$ms->migrate('latest', true);
if ($previousVersion) {
OC_App::executeRepairSteps($appId, $info['repair-steps']['post-migration']);
}
@ -601,20 +599,8 @@ class Installer {
$appPath = OC_App::getAppPath($app);
\OC_App::registerAutoloading($app, $appPath);
if (is_file("$appPath/appinfo/database.xml")) {
try {
OC_DB::createDbFromStructure("$appPath/appinfo/database.xml");
} catch (TableExistsException $e) {
throw new HintException(
'Failed to enable app ' . $app,
'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer noopener">support channels</a>.',
0, $e
);
}
} else {
$ms = new \OC\DB\MigrationService($app, \OC::$server->get(Connection::class));
$ms->migrate('latest', true);
}
$ms = new MigrationService($app, \OC::$server->get(Connection::class));
$ms->migrate('latest', true);
//run appinfo/install.php
self::includeAppScript("$appPath/appinfo/install.php");

View File

@ -972,6 +972,11 @@ class OC_App {
return false;
}
if (is_file($appPath . '/appinfo/database.xml')) {
\OC::$server->getLogger()->error('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
return false;
}
\OC::$server->getAppManager()->clearAppsCache();
$appData = self::getAppInfo($appId);
@ -987,12 +992,8 @@ class OC_App {
self::registerAutoloading($appId, $appPath, true);
self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
if (file_exists($appPath . '/appinfo/database.xml')) {
OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
} else {
$ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class));
$ms->migrate();
}
$ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class));
$ms->migrate();
self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);