Search code examples
postgresqlsymfonydoctrine-orm

Doctrine 2.2+ wants to recreate all my tables because it's attempting to use the wrong postgres schema


I updated doctrine from 2.1 to 2.2 on a symfony 2.0 project.

But now every time I try to do php app/console doctrine:schema:update doctrine wants to recreate all my schema and I have the following error:

Duplicate table: 7 ERREUR: the relation account already exists.

When I dump the SQL, it is clearly recreating all the database.


Solution

  • When upgrading from 2.1 to 2.2, Doctrine now tries to specify the schema.

    In doctrine 2.1: You can't specify the Schema, and Doctrine will create tables in the public schema

    In doctrine 2.2+: If no schema is specified, Doctrine will write into the user schema and then in the public schema.

    To specify the schema for the user that's performing the queries, just do:

    alter user your_user set search_path = my_schema