summaryrefslogtreecommitdiffstats
path: root/lib/private/db
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-17 12:51:30 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-17 12:51:30 +0200
commit6e1881dbe42dbd7f3c7c2afdc446fe6fc5d46e87 (patch)
tree0811cfbff6d3461b6b0748ebc4f109a668e7701b /lib/private/db
parentfe1df961c14079313ff7fed591283e0b9e199f38 (diff)
downloadnextcloud-server-6e1881dbe42dbd7f3c7c2afdc446fe6fc5d46e87.tar.gz
nextcloud-server-6e1881dbe42dbd7f3c7c2afdc446fe6fc5d46e87.zip
new console command to generate sql migration scripts
Diffstat (limited to 'lib/private/db')
-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;
+ }
}