Symfony Doctrine迁移,我如何使用多个实体管理器 [英] Symfony Doctrine Migrations, how can I use multiple entity managers

查看:223
本文介绍了Symfony Doctrine迁移,我如何使用多个实体管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Symfony 2.5和Doctrine 2.2,我有几个数据库用于我正在处理的应用程序,让我们称之为主和另一个辅助。目前已经配置了两个实体管理器。在一次迁移中,我想在Secondary中创建一个表,但它只是要在Main中创建表。

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."

迁移可以是ContainerAware,所以我可以得到另一个EntityManager,但是我一直无法覆盖默认的EntityManager。有能力帮忙吗?感谢提前!

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!

推荐答案

生成时只需通过 - em 参数 DIFF

Just pass --em parameter when generating diff.

示例:

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/

这篇关于Symfony Doctrine迁移,我如何使用多个实体管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆