|
|
@ -61,6 +61,7 @@ class MDB2SchemaManager { |
|
|
|
$toSchema = $schemaReader->loadSchemaFromFile($file); |
|
|
|
$toSchema = $schemaReader->loadSchemaFromFile($file); |
|
|
|
|
|
|
|
|
|
|
|
// remove tables we don't know about |
|
|
|
// remove tables we don't know about |
|
|
|
|
|
|
|
/** @var $table \Doctrine\DBAL\Schema\Table */ |
|
|
|
foreach($fromSchema->getTables() as $table) { |
|
|
|
foreach($fromSchema->getTables() as $table) { |
|
|
|
if (!$toSchema->hasTable($table->getName())) { |
|
|
|
if (!$toSchema->hasTable($table->getName())) { |
|
|
|
$fromSchema->dropTable($table->getName()); |
|
|
|
$fromSchema->dropTable($table->getName()); |
|
|
@ -76,12 +77,6 @@ class MDB2SchemaManager { |
|
|
|
$comparator = new \Doctrine\DBAL\Schema\Comparator(); |
|
|
|
$comparator = new \Doctrine\DBAL\Schema\Comparator(); |
|
|
|
$schemaDiff = $comparator->compare($fromSchema, $toSchema); |
|
|
|
$schemaDiff = $comparator->compare($fromSchema, $toSchema); |
|
|
|
|
|
|
|
|
|
|
|
$platform = $this->conn->getDatabasePlatform(); |
|
|
|
|
|
|
|
$tables = $schemaDiff->newTables + $schemaDiff->changedTables + $schemaDiff->removedTables; |
|
|
|
|
|
|
|
foreach($tables as $tableDiff) { |
|
|
|
|
|
|
|
$tableDiff->name = $platform->quoteIdentifier($tableDiff->name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($generateSql) { |
|
|
|
if ($generateSql) { |
|
|
|
return $this->generateChangeScript($schemaDiff); |
|
|
|
return $this->generateChangeScript($schemaDiff); |
|
|
|
} |
|
|
|
} |
|
|
@ -110,6 +105,7 @@ class MDB2SchemaManager { |
|
|
|
$schemaReader = new MDB2SchemaReader(\OC_Config::getObject(), $this->conn->getDatabasePlatform()); |
|
|
|
$schemaReader = new MDB2SchemaReader(\OC_Config::getObject(), $this->conn->getDatabasePlatform()); |
|
|
|
$fromSchema = $schemaReader->loadSchemaFromFile($file); |
|
|
|
$fromSchema = $schemaReader->loadSchemaFromFile($file); |
|
|
|
$toSchema = clone $fromSchema; |
|
|
|
$toSchema = clone $fromSchema; |
|
|
|
|
|
|
|
/** @var $table \Doctrine\DBAL\Schema\Table */ |
|
|
|
foreach($toSchema->getTables() as $table) { |
|
|
|
foreach($toSchema->getTables() as $table) { |
|
|
|
$toSchema->dropTable($table->getName()); |
|
|
|
$toSchema->dropTable($table->getName()); |
|
|
|
} |
|
|
|
} |
|
|
|