Skip to content

option --em does nothing for me #507

Open
@lbcd

Description

@lbcd

Hello,

I use "doctrine/doctrine-migrations-bundle": "3.2.4" in a Symfony project with two databases.

Here is my configuration:

doctrine:
    dbal:
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
            bordereau:
                url: '%env(resolve:DATABASE_BORDEREAU_URL)%'
        default_connection: default
    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                auto_mapping: true
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
            bordereau:
                connection: bordereau
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                mappings:
                    Bordereau:
                        is_bundle: false
                        type: attribute
                        dir: '%kernel.project_dir%/src/Entity/Bordereau'
                        prefix: 'App\Entity\Bordereau'
                        alias: Bordereau
doctrine_migrations:
    em: default
    migrations_paths:
        # namespace is arbitrary but should be different from App\Migrations
        # as migrations classes should NOT be autoloaded
        DoctrineMigrations: '%kernel.project_dir%/migrations/gli-agrement'
        DoctrineMigrationsBordereau: '%kernel.project_dir%/migrations/bordereau'

Project work perfect, but I have executed query on database without migration bundle. And I would like to reset this important functionality.

First question : how it can detect which migrations directory go with which entityManager ?

It is ok when I execute command bin/console doctrine:m:diff -v --em=bordereau but it put a file in '%kernel.project_dir%/migrations/gli-agrement' while I would like to get it in bordereau directory.

Then when I execute bin/console doctrine:m:m -v --em=bordereau it try to play '%kernel.project_dir%/migrations/gli-agrement' migrations in my bordereau database.

I didn't find the way to associate migrations to an entityManager. The config doc doesn't explain how to configure that. I suppose we should have something like it was specified here : #364 (comment)

doctrine_migrations:
    # default_connection: foo #(to specify a connection if there is not a "default" named connection there?)
    connections:
        default:
            migrations_paths:
                'DoctrineMigrations\Main': '%kernel.project_dir%/migrations/Main'
        geonames:
            migrations_paths:
                'DoctrineMigrations\Geonames': '%kernel.project_dir%/migrations/Geonames'

Something missing here : https://symfony.com/doc/current/doctrine/multiple_entity_managers.html
And here too : https://symfony.com/bundles/DoctrineMigrationsBundle/current/index.html
about multiple connections.

I have tried another way:

bin/console d:m:m --configuration=config/packages/doctrine_migrations_bordereau.yaml --dry-run --em=bordereau

with this config :

# config/packages/doctrine_migrations_bordereau.yaml
doctrine_migrations:
    em: bordereau
    migrations_paths:
        # namespace is arbitrary but should be different from App\Migrations
        # as migrations classes should NOT be autoloaded
        DoctrineMigrations: '%kernel.project_dir%/migrations/bordereau'

But I get this error : Migrations configuration key "doctrine_migrations" does not exist. which is mentioned in this thread #341 and should have been fixed since 2020. So I don't understand

Many thanks in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions