use injected config object and fix typos
This commit is contained in:
parent
de25084def
commit
dbc465de97
|
@ -266,7 +266,7 @@ class ConvertType extends Command {
|
||||||
$this->copyTable($fromDB, $toDB, $table, $input, $output);
|
$this->copyTable($fromDB, $toDB, $table, $input, $output);
|
||||||
}
|
}
|
||||||
if ($input->getArgument('type') === 'pgsql') {
|
if ($input->getArgument('type') === 'pgsql') {
|
||||||
$tools = new \OC\DB\PgSqlTools;
|
$tools = new \OC\DB\PgSqlTools($this->config);
|
||||||
$tools->resynchronizeDatabaseSequences($toDB);
|
$tools->resynchronizeDatabaseSequences($toDB);
|
||||||
}
|
}
|
||||||
// save new database config
|
// save new database config
|
||||||
|
|
|
@ -10,18 +10,20 @@ class OC_DB_MDB2SchemaWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
|
* @param \OC\DB\Connection $conn
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
static public function saveSchemaToFile($file, $conn) {
|
static public function saveSchemaToFile($file, \OC\DB\Connection $conn) {
|
||||||
|
$config = \OC::$server->getConfig();
|
||||||
|
|
||||||
$xml = new SimpleXMLElement('<database/>');
|
$xml = new SimpleXMLElement('<database/>');
|
||||||
$xml->addChild('name', OC_Config::getValue( "dbname", "owncloud" ));
|
$xml->addChild('name', $config->getSystemValue('dbname', 'owncloud'));
|
||||||
$xml->addChild('create', 'true');
|
$xml->addChild('create', 'true');
|
||||||
$xml->addChild('overwrite', 'false');
|
$xml->addChild('overwrite', 'false');
|
||||||
$xml->addChild('charset', 'utf8');
|
$xml->addChild('charset', 'utf8');
|
||||||
|
|
||||||
$conn->getConfiguration()->
|
$conn->getConfiguration()->
|
||||||
setFilterSchemaAssetsExpression('/^'.\OCP\Config::getSystemValue('dbtableprefix'.'/'));
|
setFilterSchemaAssetsExpression('/^' . $config->getSystemValue('dbtableprefix') . '/');
|
||||||
|
|
||||||
foreach ($conn->getSchemaManager()->listTables() as $table) {
|
foreach ($conn->getSchemaManager()->listTables() as $table) {
|
||||||
self::saveTable($table, $xml->addChild('table'));
|
self::saveTable($table, $xml->addChild('table'));
|
||||||
|
|
|
@ -77,7 +77,7 @@ class Migrator {
|
||||||
$tables = $targetSchema->getTables();
|
$tables = $targetSchema->getTables();
|
||||||
|
|
||||||
$this->connection->getConfiguration()->
|
$this->connection->getConfiguration()->
|
||||||
setFilterSchemaAssetsExpression('/^'.\OCP\Config::getSystemValue('dbtableprefix').'/');
|
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix') . '/');
|
||||||
$existingTables = $this->connection->getSchemaManager()->listTableNames();
|
$existingTables = $this->connection->getSchemaManager()->listTableNames();
|
||||||
|
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
|
@ -162,7 +162,7 @@ class Migrator {
|
||||||
|
|
||||||
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
|
protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection) {
|
||||||
$connection->getConfiguration()->
|
$connection->getConfiguration()->
|
||||||
setFilterSchemaAssetsExpression('/^'.\OCP\Config::getSystemValue('dbtableprefix').'/');
|
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix') . '/');
|
||||||
$sourceSchema = $connection->getSchemaManager()->createSchema();
|
$sourceSchema = $connection->getSchemaManager()->createSchema();
|
||||||
|
|
||||||
// remove tables we don't know about
|
// remove tables we don't know about
|
||||||
|
|
|
@ -8,11 +8,23 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace OC\DB;
|
namespace OC\DB;
|
||||||
|
use OCP\IConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Various PostgreSQL specific helper functions.
|
* Various PostgreSQL specific helper functions.
|
||||||
*/
|
*/
|
||||||
class PgSqlTools {
|
class PgSqlTools {
|
||||||
|
|
||||||
|
/** @var \OCP\IConfig */
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \OCP\IConfig $config
|
||||||
|
*/
|
||||||
|
public function __construct(IConfig $config) {
|
||||||
|
$this->config = $config;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resynchronizes all sequences of a database after using INSERTs
|
* @brief Resynchronizes all sequences of a database after using INSERTs
|
||||||
* without leaving out the auto-incremented column.
|
* without leaving out the auto-incremented column.
|
||||||
|
@ -22,7 +34,7 @@ class PgSqlTools {
|
||||||
public function resynchronizeDatabaseSequences(Connection $conn) {
|
public function resynchronizeDatabaseSequences(Connection $conn) {
|
||||||
$databaseName = $conn->getDatabase();
|
$databaseName = $conn->getDatabase();
|
||||||
$conn->getConfiguration()->
|
$conn->getConfiguration()->
|
||||||
setFilterSchemaAssetsExpression('/^'.\OCP\Config::getSystemValue('dbtableprefix').'/');
|
setFilterSchemaAssetsExpression('/^' . $this->config->getSystemValue('dbtableprefix') . '/');
|
||||||
|
|
||||||
foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
|
foreach ($conn->getSchemaManager()->listSequences() as $sequence) {
|
||||||
$sequenceName = $sequence->getName();
|
$sequenceName = $sequence->getName();
|
||||||
|
|
Loading…
Reference in New Issue