Symfony Doctrine Migrations, how can I use multipl

2019-07-15 19:37发布

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条回答
Summer. ? 凉城
2楼-- · 2019-07-15 20:09

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/
查看更多
登录 后发表回答