最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Symfony 7.2 and Doctrine Migrations with two different databases - Stack Overflow

programmeradmin0浏览0评论

I have troubles to execute properly the migrations between two different databases with Doctrine.

Here my Doctrine debug information:

Current configuration for extension with alias "doctrine_migrations"
====================================================================

doctrine_migrations:
    migrations_paths:
        App\Module\Module1\Resource\Migration: /var/www/html/src/Module/Module1/Resource/Migration
        App\Module\Module2\Resource\Migration: /var/www/html/src/Module/Module2/Resource/Migration
    em: module1
    enable_profiler: false
    services: {  }
    factories: {  }
    storage:
        table_storage:
            table_name: null
            version_column_name: null
            version_column_length: null
            executed_at_column_name: null
            execution_time_column_name: null
    migrations: {  }
    connection: null
    all_or_nothing: false
    check_database_platform: true
    custom_template: null
    organize_migrations: false
    transactional: true

The migration paths are detected but when I try to execute the migration with the corresponding entity manager it executes both migrations in one database:

php bin/console doctrine:migrations:migrate --env=dev --no-interaction --em=module1

My doctrine.yaml

doctrine:
    dbal:
        connections:
            module1:
                url: '%env(resolve:DATABASE_MODULE1_URL)%'
                driver: 'pdo_mysql'
                server_version: '8.0'
                charset: utf8mb4
                mapping_types:
                    enum: string
            module2:
                url: '%env(resolve:DATABASE_MODULE2_URL)%'
                driver: 'pdo_mysql'
                server_version: '8.0'
                charset: utf8mb4
                mapping_types:
                    enum: string

    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: module1
        entity_managers:
            module1:
                connection: module1
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                mappings:
                    Module1:
                        is_bundle: false
                        dir: '%kernel.project_dir%/src/Module/Module1/Entity'
                        prefix: 'App\Module\Module1\Entity'
                        alias: Module1
            module2:
                connection: module2
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                mappings:
                    Module2:
                        is_bundle: false
                        dir: '%kernel.project_dir%/src/Module/Module2/Entity'
                        prefix: 'App\Module\Module2\Entity'
                        alias: Module2

Here is my doctrine_migrations.yaml

imports:
    - { resource: '../../src/Module/Module1/Resource/Config/Package/doctrine_migrations.yaml' }
    - { resource: '../../src/Module/Module2/Resource/Config/Package/doctrine_migrations.yaml' }

doctrine_migrations:
    enable_profiler: false

And the single configurations:

Module1:

doctrine_migrations:
  migrations_paths:
    'App\Module\Module1\Resource\Migration': '%kernel.project_dir%/src/Module/Module1/Resource/Migration'
  em: module1

What I am missing?

发布评论

评论列表(0)

  1. 暂无评论