Skip to content


DBAL-669: Postgresql platform schema creation fails if it already exists #1889

doctrinebot opened this Issue · 5 comments

2 participants


Jira issue originally created by user chrisramakers:

This patch (fabe3c3) introduced a bug where the schemaNeedsCreation method always returns true if the schema name isn't 'default' or 'public'.

We heavily use schema's in our application and whenever an insert query is queued, it fails because the schema in question already exists but the platform adapter fails to detect that and continues with a "CREATE SCHEMA" query which fails.

The easy fix is to add the 'IF NOT EXISTS' clause to the 'CREATE SCHEMA' query but that will only function on Postgresql 9.3 and upward since 'IF NOT EXISTS' wasn't possible in earlier versions for schema creation.

Beter would be to load the existing schema's and compare them to those. I would create a pull request but i'm not sure how to obtain a database connection in the Platform (if at all possible) to pull a list of already known schema's?


Comment created by @ocramius:

[~chrisramakers] I'm trying to look into it. The method schemaNeedsCreation seems indeed to be wrong.


Comment created by @ocramius:

Provided a fix for this at #444

We won't fix the schema creation command, since it is supposed to fail on already existing conflicting elements (tables/etc)


Comment created by chrisramakers:

Any news on this? The bug keeps causing problems every time we deploy a new version. We are practically required to edit the vendor files for doctrine in our project so this bug doesn't cause issues.


Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label
@deeky666 deeky666 was assigned by doctrinebot
@doctrinebot doctrinebot added this to the 2.5 milestone
@doctrinebot doctrinebot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.