diff options
author | Morris Jobke <hey@morrisjobke.de> | 2021-03-24 20:27:39 +0100 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2021-03-24 22:15:44 +0100 |
commit | ab48d5e8cbb653767070a286650b87ae97461f37 (patch) | |
tree | 57888a2d7b536c94bcc309e33566ea0db840c2d7 /lib/private/DB/Connection.php | |
parent | bb0c50717cd604ffeafacafe901a70c894ed29f3 (diff) | |
download | nextcloud-server-ab48d5e8cbb653767070a286650b87ae97461f37.tar.gz nextcloud-server-ab48d5e8cbb653767070a286650b87ae97461f37.zip |
Cleanup unneeded code around database.xml
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib/private/DB/Connection.php')
-rw-r--r-- | lib/private/DB/Connection.php | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 4d9433122ce..941d8628ca0 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -44,6 +44,9 @@ use Doctrine\DBAL\Exception; 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; @@ -509,8 +512,7 @@ class Connection extends \Doctrine\DBAL\Connection { * @throws Exception */ public function createSchema() { - $schemaManager = new MDB2SchemaManager($this); - $migrator = $schemaManager->getMigrator(); + $migrator = $this->getMigrator(); return $migrator->createSchema(); } @@ -522,8 +524,26 @@ class Connection extends \Doctrine\DBAL\Connection { * @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); + } + } } |