问题描述
我遇到了与此处报告的相同的问题:Doctrine 2.2想重新创建我所有的表
I have the same problem as reported here: Doctrine 2.2 wants to recreate all my tables
我使用的是 PostgreSQL,我的表在公共架构中.
I'm using PostgreSQL and my tables are in the public schema.
app/console algorithm:schema:update 想要重新创建我的所有表,显然是因为它正在查看用户架构,而不是公共架构.我的 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
模式以防 PostgreSQL 由于某种原因回退到另一个模式——@Table
注释具有 schema
属性:
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 DoctrineORMMappingTable;
/**
* @Table(schema="some_schema")
*/
class Entity
{
// ...
}
这篇关于如何指定用于 Doctrine 2.2/Symfony 2.2 和 PostgreSQL 的模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!