diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/db/mdb2schemamanager.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php index 8e76f46c78f..fc13e881bff 100644 --- a/lib/private/db/mdb2schemamanager.php +++ b/lib/private/db/mdb2schemamanager.php @@ -53,7 +53,7 @@ class MDB2SchemaManager { * @param string $file file to read structure from * @return bool */ - public function updateDbFromStructure($file) { + public function updateDbFromStructure($file, $generateSql = false) { $sm = $this->conn->getSchemaManager(); $fromSchema = $sm->createSchema(); @@ -82,6 +82,10 @@ class MDB2SchemaManager { $tableDiff->name = $platform->quoteIdentifier($tableDiff->name); } + if ($generateSql) { + return $this->generateChangeScript($schemaDiff); + } + return $this->executeSchemaChange($schemaDiff); } @@ -147,4 +151,20 @@ class MDB2SchemaManager { $this->conn->commit(); return true; } + + /** + * @param \Doctrine\DBAL\Schema\Schema $schema + * @return string + */ + public function generateChangeScript($schema) { + + $script = ''; + $sqls = $schema->toSql($this->conn->getDatabasePlatform()); + foreach($sqls as $sql) { + $script .= $sql . ';'; + $script .= PHP_EOL; + } + + return $script; + } } |