How do I use make:migration with multiple entity managers?

I’m using Symfony 5.1.5

I’ve configured multiple entity managers. Here’s my doctrine.yaml file:

doctrine:
    dbal:
        default_connection: master
        connections:
            master:
                url: '%env(resolve:MASTER_DATABASE_URL)%'
            client:
                url: '~'

    orm:
        default_entity_manager: master
        auto_generate_proxy_classes: true
        entity_managers:
            master:
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                connection: master
                mappings:
                    AppMaster:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Master'
                        prefix: 'AppEntityMaster'
                        alias: Master
            client: 
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                connection: client
                mappings:
                    AppClient:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity/Client'
                        prefix: 'AppEntityClient'
                        alias: Client

Here’s my doctrine_migrations.yaml file:

doctrine_migrations:
    em: 'master'
    migrations_paths:
        'DoctrineMigrations': '%kernel.project_dir%/migrations'

I have two entities
AppEntityMasterSubdomain
AppEntityClientUser

When I run symfony console make:migration it only works with Master entity manager.

Looking at https://symfony.com/doc/current/doctrine/multiple_entity_managers.html
they use these commands as examples

 php bin/console doctrine:migrations:diff --em=customer
 php bin/console doctrine:migrations:migrate --em=customer

However when I try to run php bin/console doctrine:migrations:diff –em=customer I get an error saying "The "–em" option does not exist."

How can I make it generate migrations for the Client entity manager as well?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 1

Your email address will not be published. Required fields are marked *


Alexandre

Alexandre

same shit