Doctrine映射和PostgreSQL模式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Doctrine映射和PostgreSQL模式相关的知识,希望对你有一定的参考价值。
我有两个Symfony应用程序映射到相同的PgSQL数据库。两个应用程序都使用FOSUserBundle,所以我试图处理不同模式的用户。阅读并对Google进行一些研究我按照以下方式构建我的实体:
/**
* @ORMEntity
* @ORMTable(name="internal_users", schema="internal")
* @GedmoSoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class InternalUser extends BaseUser
{
...
}
然后我从Symfony2 shell尝试了以下内容:
Symfony > doctrine:schema:validate
[Mapping] OK - The mapping files are correct.
[Database] FAIL - The database schema is not in sync with the current mapping file.
The command terminated with an error status (2)
Symfony > doctrine:schema:update --force
Updating database schema...
Database schema updated successfully! "14" queries were executed
Symfony >
但是表格是在public
架构上生成的,而不是在我想要的internal
架构中,我做错了什么?有什么方法可以在不同的模式中创建表吗?
答案
作为解决方法,您可以使用SCHEMA.TABLE
作为表名:
@ORMTable(name="internal.internal_users")
另一答案
从Doctrine ORM 2.5开始,您可以使用schema
属性:
@ORMTable(schema="internal")
以上是关于Doctrine映射和PostgreSQL模式的主要内容,如果未能解决你的问题,请参考以下文章
如何使Doctrine PostgreSQL外键约束DEFERRABLE
我应该在 Doctrine 2 中使用 YAML/XML 还是注解映射?
PostgreSQL 和 Oracle 对象关系存储是不是与 ORM 相同?