Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Bye bye database.xml
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and MorrisJobke committed Mar 24, 2021
commit bb0c50717cd604ffeafacafe901a70c894ed29f3
18 changes: 7 additions & 11 deletions core/Command/Db/ConvertType.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,13 @@ protected function createSchema(Connection $fromDB, Connection $toDB, InputInter
$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);
}
}
}
Expand Down
36 changes: 11 additions & 25 deletions lib/private/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
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;
Expand Down Expand Up @@ -114,6 +114,11 @@ public function installApp(string $appId, bool $forceEnable = false): string {
}

$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');
Expand Down Expand Up @@ -152,16 +157,9 @@ public function installApp(string $appId, bool $forceEnable = false): string {
}

//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']);
}
Expand Down Expand Up @@ -601,20 +599,8 @@ public static function installShippedApp($app) {
$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");
Expand Down
13 changes: 7 additions & 6 deletions lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,11 @@ public static function updateApp(string $appId): bool {
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);

Expand All @@ -987,12 +992,8 @@ public static function updateApp(string $appId): bool {
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']);
Expand Down