summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-10-17 04:53:18 -0700
committerMorris Jobke <morris.jobke@gmail.com>2013-10-17 04:53:18 -0700
commit9c8d1190c0295e4ded8e9812d842af5c65679926 (patch)
treeb83ebbee10f4cb84a0a204723362f74b3b6b1101 /lib
parentd2b1a361cca422fee0f9d05b272d07637235e0ea (diff)
parent6e1881dbe42dbd7f3c7c2afdc446fe6fc5d46e87 (diff)
downloadnextcloud-server-9c8d1190c0295e4ded8e9812d842af5c65679926.tar.gz
nextcloud-server-9c8d1190c0295e4ded8e9812d842af5c65679926.zip
Merge pull request #5385 from owncloud/generate-sql-migration-master
new console command to generate sql migration scripts
Diffstat (limited to 'lib')
-rw-r--r--lib/private/db/mdb2schemamanager.php22
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;
+ }
}