Doctrine映射和PostgreSQL模式

问题描述 投票:5回答:2

我有两个Symfony应用程序映射到相同的PgSQL数据库。两个应用程序都使用FOSUserBundle,所以我试图处理不同模式的用户。阅读并对Google进行一些研究我按照以下方式构建我的实体:

/**
 * @ORM\Entity
 * @ORM\Table(name="internal_users", schema="internal")
 * @Gedmo\SoftDeleteable(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架构中,我做错了什么?有什么方法可以在不同的模式中创建表吗?

php postgresql symfony doctrine-orm database-schema
2个回答
4
投票

作为解决方法,您可以使用SCHEMA.TABLE作为表名:

@ORM\Table(name="internal.internal_users")

0
投票

从Doctrine ORM 2.5开始,您可以使用schema属性:

@ORM\Table(schema="internal")

Reference

© www.soinside.com 2019 - 2024. All rights reserved.