如何更改config.yml中的默认迁移目录?现在,我正在使用两个具有不同数据库连接的捆绑包,我想创建迁移文件并将它们存储在不同的目录中,以使用原理: migrations :migrate--em=依赖于捆绑包的任何函数。
例如:
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发布于 2013-06-12 21:34:15
如果您将为第二个连接/包创建单独的实体管理器,您将在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 发布于 2019-05-31 02:32:15
对于Symfony 4,推荐的方法是改用%kernel.project_dir%,并将其放在由App\命名的src/文件夹中
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/DoctrineMigrations'
namespace: 'App\DoctrineMigrations'https://stackoverflow.com/questions/17066670
复制相似问题