I have two Symfony applications mapped to the same PgSQL database. Both applications use FOSUserBundle so I'm trying to handle users in different schemas. Reading and doing some research on Google I build my entities as follow:
/**
* @ORM\Entity
* @ORM\Table(name="internal_users", schema="internal")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class InternalUser extends BaseUser
{
...
}
Then I tried from Symofny2 shell the following:
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 >
But tables was generated on public
schema and not in internal
schema as I want, what I did wrong? Any way to create the tables in different schemas?
As a workaround, you can use SCHEMA.TABLE
as table name:
@ORM\Table(name="internal.internal_users")
Since Doctrine ORM 2.5 you can use the schema
attribute (Reference):
@ORM\Table(schema="internal")
Or use schema
option in yaml driver:
App\Entity\InternalUser:
table: internal_users
schema: internal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With