如果您将为第二个连接/捆绑创建单独的实体管理器,您将在 DoctrineMigrations 目录中获得另一个目录。例如:
app/
DoctrineMigrations/
entityManager1/
entityManager2/
如果你想把所有迁移到另一个目录,你可以在你的 config.yml 中设置它:
doctrine_migrations:
dir_name: '%kernel.root_dir%/../Acme/CommonBundle/DoctrineMigrations'
namespace: 'Acme\CommonBundle\DoctrineMigrations'
如果您想要一些更复杂的事情,例如将迁移从 em1 到 dir1 放在 bundle1 中,并将从 em2 迁移到 dir2 放在 bundle2 中,您将需要另外两个配置文件,您将在其中指定特定捆绑包的目录:
http://docs.doctrine-project.org/projects/doctrine-migrations/en/latest/reference/introduction.html#configuration
然后你像这样运行你的迁移:
doctrine:migrations:status --em=em1 --configuration=./path/to/bundle1/Resources/config/migrations.yml
doctrine:migrations:status --em=em2 --configuration=./path/to/bundle2/Resources/config/migrations.yml
通过https://github.com/doctrine/DoctrineMigrationsBundle/pull/46,migrations.yml
文件应如下所示:
name: Doctrine Postgres Migrations
migrations_namespace: Application\Migrations
table_name: migration_versions
migrations_directory: PostgreSqlMigrations