如何指定使用Doctrine 2.2 / Symfony 2.2和PostgreSQL的架构? [英] How do I specify which schema to use for Doctrine 2.2 / Symfony 2.2 and PostgreSQL?
问题描述
我有同样的问题:教义2.2想要重新创建我的所有表格
我使用的是PostgreSQL,我的表格在公共模式中。
I'm using PostgreSQL and my tables are in the public schema.
app / console doctrine:schema:update想要重新创建所有的表,显然是因为它在用户模式中查找,而不是public。我的Symfony应用程序工作正常,因为它似乎有点奇怪。
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.
使用Symfony 2.2 / Doctrine 2.2在哪里指定模式?我似乎无法在任何文件中找到它。
With Symfony 2.2 / Doctrine 2.2 where do I specify the schema? I can't seem to find it in any documentation.
推荐答案
如果您使用 public
模式,您不需要做任何特别的操作,因为PostgreSQL会自动回退到。
If you're using the public
schema, you don't have to do anything special, because PostgreSQL fallbacks to it automatically.
但是,如果要指定其他模式 - 或者强制使用 public
schema,以防PostgreSQL由于某种原因而退回到另一个 - @Table
注释拥有 架构
property :
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
{
// ...
}
这篇关于如何指定使用Doctrine 2.2 / Symfony 2.2和PostgreSQL的架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!