Skip to content

Commit

Permalink
Cleanup unneeded code around database.xml
Browse files Browse the repository at this point in the history
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Mar 24, 2021
1 parent bb0c507 commit 25316f1
Show file tree
Hide file tree
Showing 25 changed files with 24 additions and 4,035 deletions.
1 change: 0 additions & 1 deletion core/Command/Db/ConvertType.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ protected function createSchema(Connection $fromDB, Connection $toDB, InputInter
$toMS->migrate($currentMigration);
}

$schemaManager = new \OC\DB\MDB2SchemaManager($toDB);
$apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
foreach ($apps as $app) {
$output->writeln('<info> - '.$app.'</info>');
Expand Down
206 changes: 0 additions & 206 deletions core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php

This file was deleted.

1 change: 0 additions & 1 deletion core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getAppManager()));
$application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->get(\OC\DB\Connection::class)));
$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->get(\OC\DB\Connection::class), \OC::$server->getConfig()));

$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
Expand Down
28 changes: 24 additions & 4 deletions lib/private/DB/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
use Doctrine\DBAL\Exception\ConstraintViolationException;
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Statement;
Expand Down Expand Up @@ -509,8 +512,7 @@ public function supports4ByteText() {
* @throws Exception
*/
public function createSchema() {
$schemaManager = new MDB2SchemaManager($this);
$migrator = $schemaManager->getMigrator();
$migrator = $this->getMigrator();
return $migrator->createSchema();
}

Expand All @@ -522,8 +524,26 @@ public function createSchema() {
* @throws Exception
*/
public function migrateToSchema(Schema $toSchema) {
$schemaManager = new MDB2SchemaManager($this);
$migrator = $schemaManager->getMigrator();
$migrator = $this->getMigrator();
$migrator->migrate($toSchema);
}

private function getMigrator() {
// TODO properly inject those dependencies
$random = \OC::$server->getSecureRandom();
$platform = $this->getDatabasePlatform();
$config = \OC::$server->getConfig();
$dispatcher = \OC::$server->getEventDispatcher();
if ($platform instanceof SqlitePlatform) {
return new SQLiteMigrator($this, $config, $dispatcher);
} elseif ($platform instanceof OraclePlatform) {
return new OracleMigrator($this, $config, $dispatcher);
} elseif ($platform instanceof MySQLPlatform) {
return new MySQLMigrator($this, $config, $dispatcher);
} elseif ($platform instanceof PostgreSQL94Platform) {
return new PostgreSqlMigrator($this, $config, $dispatcher);
} else {
return new Migrator($this, $config, $dispatcher);
}
}
}
Loading

0 comments on commit 25316f1

Please sign in to comment.