Symfony Doctrine Migrations, how can I use multiple entity managers

喜你入骨 提交于 2019-12-24 03:56:06

问题


Using Symfony 2.5 and Doctrine 2.2, I have several databases for an application I'm working on, let's call one "Main" and the other "Secondary". There are currently two entity managers configured. In one migration I want to create a table in "Secondary" but it only wants to create the table in "Main."

A migration can be ContainerAware, so I can get another EntityManager, but I have been unable to override the default one. Any able to help? Thanks in advance!


回答1:


Just pass --em parameter when generating diff.

Example:

php app/console doctrine:migrations:diff --em=uac # will use uac entity manager
php app/console doctrine:migrations:diff # will use the default entity manager

To exclude custom tables from removal use:

doctrine:
    dbal:
        schema_filter: ~^(?!t_)~

as per this document, alternatively you can pass filter argument at the runtime:

app/console doctrine:migrations:diff  --em=uac --filter-expression=/whatever/


来源:https://stackoverflow.com/questions/27115881/symfony-doctrine-migrations-how-can-i-use-multiple-entity-managers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!