gpt4 book ai didi

Symfony2 - 更改迁移目录

转载 作者:行者123 更新时间:2023-12-03 15:11:18 24 4
gpt4 key购买 nike

如何更改 config.yml 中的默认迁移目录?
现在我正在使用 2 个具有不同 db-connections 的包,我想创建迁移文件并将它们存储在不同的目录中,以使用该包依赖的 dotric:migrations:migrate --em=whatever 函数。

例如:

doctrine:migrate:diff --em=whatever #creating a version file in the DoctrineMigrationsWhatever directory

php app/console doctrine:migrations:status --em=whatever # shows only the version files, that belong to the bundle

最佳答案

如果您将为第二个连接/bundle 创建单独的实体管理器,您将在 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

关于Symfony2 - 更改迁移目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17066670/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com