Doctrine DBAL
  1. Doctrine DBAL
  2. DBAL-669

Postgresql platform schema creation fails if it already exists

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.4, 2.4.1
    • Fix Version/s: 2.5
    • Component/s: Platforms
    • Security Level: All
    • Labels:
      None
    • Environment:
      Postgresql 8.3.14 on CentOS6
      Also happens on Postgresql 9.2 on the same box

      Description

      This patch (https://github.com/doctrine/dbal/commit/fabe3c346b24dcb70eba0cb3936998ec6cc152f0) 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?

        Issue Links

          Activity

          Hide
          Marco Pivetta added a comment -

          Chris Ramakers I'm trying to look into it. The method

          schemaNeedsCreation

          seems indeed to be wrong.

          Show
          Marco Pivetta added a comment - Chris Ramakers I'm trying to look into it. The method schemaNeedsCreation seems indeed to be wrong.
          Hide
          Marco Pivetta added a comment - - edited

          Provided a fix for this at https://github.com/doctrine/dbal/pull/444

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

          Show
          Marco Pivetta added a comment - - edited Provided a fix for this at https://github.com/doctrine/dbal/pull/444 We won't fix the schema creation command, since it is supposed to fail on already existing conflicting elements (tables/etc)
          Hide
          Chris Ramakers added a comment -

          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.

          Show
          Chris Ramakers added a comment - 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.

            People

            • Assignee:
              Steve Müller
              Reporter:
              Chris Ramakers
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: