Skip to content

Commit bb0c507

Browse files
nickvergessenMorrisJobke
authored andcommitted
Bye bye database.xml
Signed-off-by: Joas Schilling <[email protected]>
1 parent 6e40c2f commit bb0c507

File tree

3 files changed

+25
-42
lines changed

3 files changed

+25
-42
lines changed

core/Command/Db/ConvertType.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,13 @@ protected function createSchema(Connection $fromDB, Connection $toDB, InputInter
247247
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
248248
foreach ($apps as $app) {
249249
$output->writeln('<info> - '.$app.'</info>');
250-
if (file_exists(\OC_App::getAppPath($app).'/appinfo/database.xml')) {
251-
$schemaManager->createDbFromStructure(\OC_App::getAppPath($app).'/appinfo/database.xml');
252-
} else {
253-
// Make sure autoloading works...
254-
\OC_App::loadApp($app);
255-
$fromMS = new MigrationService($app, $fromDB);
256-
$currentMigration = $fromMS->getMigration('current');
257-
if ($currentMigration !== '0') {
258-
$toMS = new MigrationService($app, $toDB);
259-
$toMS->migrate($currentMigration, true);
260-
}
250+
// Make sure autoloading works...
251+
\OC_App::loadApp($app);
252+
$fromMS = new MigrationService($app, $fromDB);
253+
$currentMigration = $fromMS->getMigration('current');
254+
if ($currentMigration !== '0') {
255+
$toMS = new MigrationService($app, $toDB);
256+
$toMS->migrate($currentMigration, true);
261257
}
262258
}
263259
}

lib/private/Installer.php

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
use OC\AppFramework\Bootstrap\Coordinator;
4747
use OC\Archive\TAR;
4848
use OC\DB\Connection;
49+
use OC\DB\MigrationService;
4950
use OC_App;
50-
use OC_DB;
5151
use OC_Helper;
5252
use OCP\Http\Client\IClientService;
5353
use OCP\IConfig;
@@ -114,6 +114,11 @@ public function installApp(string $appId, bool $forceEnable = false): string {
114114
}
115115

116116
$basedir = $app['path'].'/'.$appId;
117+
118+
if (is_file($basedir . '/appinfo/database.xml')) {
119+
throw new \Exception('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
120+
}
121+
117122
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);
118123

119124
$l = \OC::$server->getL10N('core');
@@ -152,16 +157,9 @@ public function installApp(string $appId, bool $forceEnable = false): string {
152157
}
153158

154159
//install the database
155-
if (is_file($basedir.'/appinfo/database.xml')) {
156-
if (\OC::$server->getConfig()->getAppValue($info['id'], 'installed_version') === null) {
157-
OC_DB::createDbFromStructure($basedir.'/appinfo/database.xml');
158-
} else {
159-
OC_DB::updateDbFromStructure($basedir.'/appinfo/database.xml');
160-
}
161-
} else {
162-
$ms = new \OC\DB\MigrationService($info['id'], \OC::$server->get(Connection::class));
163-
$ms->migrate('latest', true);
164-
}
160+
$ms = new MigrationService($info['id'], \OC::$server->get(Connection::class));
161+
$ms->migrate('latest', true);
162+
165163
if ($previousVersion) {
166164
OC_App::executeRepairSteps($appId, $info['repair-steps']['post-migration']);
167165
}
@@ -601,20 +599,8 @@ public static function installShippedApp($app) {
601599
$appPath = OC_App::getAppPath($app);
602600
\OC_App::registerAutoloading($app, $appPath);
603601

604-
if (is_file("$appPath/appinfo/database.xml")) {
605-
try {
606-
OC_DB::createDbFromStructure("$appPath/appinfo/database.xml");
607-
} catch (TableExistsException $e) {
608-
throw new HintException(
609-
'Failed to enable app ' . $app,
610-
'Please ask for help via one of our <a href="https://nextcloud.com/support/" target="_blank" rel="noreferrer noopener">support channels</a>.',
611-
0, $e
612-
);
613-
}
614-
} else {
615-
$ms = new \OC\DB\MigrationService($app, \OC::$server->get(Connection::class));
616-
$ms->migrate('latest', true);
617-
}
602+
$ms = new MigrationService($app, \OC::$server->get(Connection::class));
603+
$ms->migrate('latest', true);
618604

619605
//run appinfo/install.php
620606
self::includeAppScript("$appPath/appinfo/install.php");

lib/private/legacy/OC_App.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,11 @@ public static function updateApp(string $appId): bool {
972972
return false;
973973
}
974974

975+
if (is_file($appPath . '/appinfo/database.xml')) {
976+
\OC::$server->getLogger()->error('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
977+
return false;
978+
}
979+
975980
\OC::$server->getAppManager()->clearAppsCache();
976981
$appData = self::getAppInfo($appId);
977982

@@ -987,12 +992,8 @@ public static function updateApp(string $appId): bool {
987992
self::registerAutoloading($appId, $appPath, true);
988993
self::executeRepairSteps($appId, $appData['repair-steps']['pre-migration']);
989994

990-
if (file_exists($appPath . '/appinfo/database.xml')) {
991-
OC_DB::updateDbFromStructure($appPath . '/appinfo/database.xml');
992-
} else {
993-
$ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class));
994-
$ms->migrate();
995-
}
995+
$ms = new MigrationService($appId, \OC::$server->get(\OC\DB\Connection::class));
996+
$ms->migrate();
996997

997998
self::executeRepairSteps($appId, $appData['repair-steps']['post-migration']);
998999
self::setupLiveMigrations($appId, $appData['repair-steps']['live-migration']);

0 commit comments

Comments
 (0)