inject \OCP\IConfig instance in migrator

This commit is contained in:
Morris Jobke 2014-12-22 10:43:56 +01:00
parent ad8d55c327
commit de25084def
3 changed files with 13 additions and 23 deletions

View File

@ -58,19 +58,19 @@ class MDB2SchemaManager {
public function getMigrator() {
$random = \OC::$server->getSecureRandom()->getMediumStrengthGenerator();
$platform = $this->conn->getDatabasePlatform();
$config = \OC::$server->getConfig();
if ($platform instanceof SqlitePlatform) {
$config = \OC::$server->getConfig();
return new SQLiteMigrator($this->conn, $random, $config);
} else if ($platform instanceof OraclePlatform) {
return new OracleMigrator($this->conn, $random);
return new OracleMigrator($this->conn, $random, $config);
} else if ($platform instanceof MySqlPlatform) {
return new MySQLMigrator($this->conn, $random);
return new MySQLMigrator($this->conn, $random, $config);
} else if ($platform instanceof SQLServerPlatform) {
return new MsSqlMigrator($this->conn, $random);
return new MsSqlMigrator($this->conn, $random, $config);
} else if ($platform instanceof PostgreSqlPlatform) {
return new Migrator($this->conn, $random);
return new Migrator($this->conn, $random, $config);
} else {
return new NoCheckMigrator($this->conn, $random);
return new NoCheckMigrator($this->conn, $random, $config);
}
}

View File

@ -14,6 +14,7 @@ use \Doctrine\DBAL\Schema\Table;
use \Doctrine\DBAL\Schema\Schema;
use \Doctrine\DBAL\Schema\SchemaConfig;
use \Doctrine\DBAL\Schema\Comparator;
use OCP\IConfig;
use OCP\Security\ISecureRandom;
class Migrator {
@ -28,13 +29,18 @@ class Migrator {
*/
private $random;
/** @var IConfig */
protected $config;
/**
* @param \Doctrine\DBAL\Connection $connection
* @param ISecureRandom $random
* @param IConfig $config
*/
public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random) {
public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, IConfig $config) {
$this->connection = $connection;
$this->random = $random;
$this->config = $config;
}
/**

View File

@ -10,25 +10,9 @@ namespace OC\DB;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use OCP\Security\ISecureRandom;
class SQLiteMigrator extends Migrator {
/**
* @var \OCP\IConfig
*/
private $config;
/**
* @param \Doctrine\DBAL\Connection $connection
* @param ISecureRandom $random
* @param \OCP\IConfig $config
*/
public function __construct(\Doctrine\DBAL\Connection $connection, ISecureRandom $random, \OCP\IConfig $config) {
parent::__construct($connection, $random);
$this->config = $config;
}
/**
* @param \Doctrine\DBAL\Schema\Schema $targetSchema
* @throws \OC\DB\MigrationException