Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I specify which schema to use for Doctrine 2.2 / Symfony 2.2 and PostgreSQL?

I have the same problem as reported here: Doctrine 2.2 wants to recreate all my tables

I'm using PostgreSQL and my tables are in the public schema.

app/console doctrine:schema:update wants to recreate all my tables, apparently because it's looking in the user schema, not public. My Symfony application works fine as it is which seems a little strange.

With Symfony 2.2 / Doctrine 2.2 where do I specify the schema? I can't seem to find it in any documentation.

like image 866
tetranz Avatar asked Mar 07 '13 19:03

tetranz


1 Answers

If you're using the public schema, you don't have to do anything special, because PostgreSQL fallbacks to it automatically.

However, if you want to specify another schema — or enforce the usage of the public schema in case PostgreSQL fallbacks to another one for some reason — the @Table annotation has the schema property:

use Doctrine\ORM\Mapping\Table;

/**
 * @Table(schema="some_schema")
 */
class Entity 
{
    // ...
}
like image 141
Elnur Abdurrakhimov Avatar answered Oct 02 '22 21:10

Elnur Abdurrakhimov