lfaveur/doctrine-migrations-multiple-database-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lfaveur/doctrine-migrations-multiple-database-bundle

Composer 安装命令:

composer require lfaveur/doctrine-migrations-multiple-database-bundle

包简介

Symfony DoctrineMigrationsMultipleDatabaseBundle

README 文档

README

This bundle extends the DoctrineMigrationsBundle functionality in a hacky and dirty way to provide a easy way to configure migrations paths for multiple entity managers.

Configuration

  • Install the package by running composer require avaibooksports/doctrine-migrations-multiple-database-bundle
  • Go to your config/bundles.php file and register the bundle:
AvaiBookSports\Bundle\MigrationsMutlipleDatabase\DoctrineMigrationsMultipleDatabaseBundle::class => ['all' => true],
  • Finally, create a file in config/packages/ called doctrine_migrations_multiple_database.yaml and follow the next example:
doctrine_migrations_multiple_database:
    entity_managers:
        default:
            migrations_paths:
                DoctrineMigrations\Main: '%kernel.project_dir%/migrations/Main'
        geonames:
            migrations_paths:
                DoctrineMigrations\Geonames: '%kernel.project_dir%/migrations/Geonames'
  • You can leave your doctirne_migrations.yaml file untouched. Unmapped commands will fallback to that configuration, and if you need to disable this bundle everything should work as always.

Usage

Just call the same commands as always, with the same parameters. See the supported commands

You can run a command for a specific entity manager adding the option --em=example

If you call any of the supported commands, they will work as always iterating over all the defined configurations.

For those commands who has a --namespace option, you have to provide always the correct entity manager. Otherwise, it will iterate over every entity manager, and will eventually fail. If you want to suggest a better workflow, please open an issue!

Supported configuration

For now, all configuration parameters should work except connection and em, because we are already specifying which entity manager we want to connect.

This would be the example configuration of DoctrineMigrationsBundle translated to this bundle:

# config/packages/doctrine_migrations_multiple_database.yaml


doctrine_migrations_multiple_database:
    entity_managers:
        default:
            # List of namespace/path pairs to search for migrations, at least one required
            migrations_paths:
                'App\Migrations': 'src/App'
                'AnotherApp\Migrations': '/path/to/other/migrations'
                'SomeBundle\Migrations': '@SomeBundle/Migrations'

            # List of additional migration classes to be loaded, optional
            migrations:
                - 'App\Migrations\Version123'
                - 'App\Migrations\Version123'

            storage:
                # Default (SQL table) metadata storage configuration
                table_storage:
                    table_name: 'doctrine_migration_versions'
                    version_column_name: 'version'
                    version_column_length: 1024
                    executed_at_column_name: 'executed_at'
                    execution_time_column_name: 'execution_time'

            # Possible values: "BY_YEAR", "BY_YEAR_AND_MONTH", false
            organize_migrations: false

            # Path to your custom migrations template
            custom_template: ~

            # Run all migrations in a transaction.
            all_or_nothing: false

            # Adds an extra check in the generated migrations to ensure that is executed on the same database type.
            check_database_platform: true

            services:
                # Custom migration sorting service id
                'Doctrine\Migrations\Version\Comparator': ~

                # Custom migration classes factory
                'Doctrine\Migrations\Version\MigrationFactory': ~

            factories:
                # Custom migration sorting service id via callables (MyCallableFactory must be a callable)
                'Doctrine\Migrations\Version\Comparator': 'MyCallableFactory'

Supported commands

  • doctrine:migrations:current
  • doctrine:migrations:diff
  • doctrine:migrations:dump-schema
  • doctrine:migrations:execute
  • doctrine:migrations:generate
  • doctrine:migrations:latest
  • doctrine:migrations:list
  • doctrine:migrations:migrate
  • doctrine:migrations:rollup
  • doctrine:migrations:status
  • doctrine:migrations:sync-metadata-storage
  • doctrine:migrations:up-to-date
  • doctrine:migrations:version

Pitfalls

This package is being actively developed to satisfy a very specific scenario in our workflow, but we wanted to share this solution with more people struggling with this particular need.

As we are basing our configuration in YAML files, XML and PHP formats are not tested right now. We would love to have feedback from you if you have any problems configuring the bundle. Unit tests should come sooner or later.

Also, we are supporting partially the configuration parameters, and not all commands are mapped.

All releases tagged like 0.x will be affected by this pitfalls, and release 1.0 will cover a full configuration file and all commands.

lfaveur/doctrine-migrations-multiple-database-bundle 适用场景与选型建议

lfaveur/doctrine-migrations-multiple-database-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「dbal」 「migrations」 「schema」 「Multiple databases」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lfaveur/doctrine-migrations-multiple-database-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lfaveur/doctrine-migrations-multiple-database-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 lfaveur/doctrine-migrations-multiple-database-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-07-07