Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added PostgreSQL schemas creation #328

Closed
wants to merge 5 commits into from

4 participants

Maxim Styushin Guilherme Blanco Steve Müller Richard Fullmer
Maxim Styushin

When doing doctrine:schema:create it puts tables only in public schema and can't create any other. Trying to specify other schema like schema_name.table_name causes an error. This patch solved it for me.

Guilherme Blanco
Owner

Points for change:

1- Use single quotes
2- Turn comparison into an identical match ===
3- Add a line break between $query and array_push

Besides that... seems ok.

lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -136,7 +136,10 @@ public function getQueries()
136 136
 
137 137
         foreach (array_keys($this->createTableQueries) as $namespace) {
138 138
             if ($this->platform->supportsSchemas()) {
139  
-                // TODO: Create Schema here
  139
+                if ($namespace != "default") {
  140
+                    $query = 'CREATE SCHEMA ' . $namespace;
1
Steve Müller Collaborator
deeky666 added a note May 31, 2013

SQL generation has to be done through the platform. I guess the platform is currently missing a createSchemaSQL() method which has to be implemented before this can work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -136,7 +136,10 @@ public function getQueries()
136 136
 
137 137
         foreach (array_keys($this->createTableQueries) as $namespace) {
138 138
             if ($this->platform->supportsSchemas()) {
139  
-                // TODO: Create Schema here
  139
+                if ($namespace != "default") {
1
Steve Müller Collaborator
deeky666 added a note May 31, 2013

I guess this is something PostgreSQL specific, right? If this is the case then this is the wrong place to filter namespaces as this method applies to all platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Maxim Styushin

Hey guys, would this PR be merged?

Steve Müller
Collaborator

Still, IMO SQL generation should go into the platform.

Richard Fullmer richardfullmer commented on the diff July 10, 2013
lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -135,8 +135,12 @@ public function getQueries()
135 135
         $sql = array();
136 136
 
137 137
         foreach (array_keys($this->createTableQueries) as $namespace) {
138  
-            if ($this->platform->supportsSchemas()) {
139  
-                // TODO: Create Schema here
  138
+            if ($this->platform->getName() === 'postgresql' ) {
1

Should be _platform instead of platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Guilherme Blanco

Closed in favor of #355

Guilherme Blanco guilhermeblanco closed this August 06, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
8  lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php
@@ -135,8 +135,12 @@ public function getQueries()
135 135
         $sql = array();
136 136
 
137 137
         foreach (array_keys($this->createTableQueries) as $namespace) {
138  
-            if ($this->platform->supportsSchemas()) {
139  
-                // TODO: Create Schema here
  138
+            if ($this->platform->getName() === 'postgresql' ) {
  139
+                if ($namespace !== 'default' and $namespace !== "public") {
  140
+                    $query = 'CREATE SCHEMA ' . $namespace;
  141
+
  142
+                    array_push($sql, $query);
  143
+                }
140 144
             }
141 145
         }
142 146
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.