doesntmattr / mongodb-migrations-bundle

Symfony MongoDBMigrationsBundle
MIT License
23 stars 27 forks source link

Doctrine MongoDB Manager named "default_document_manager" does not exist. #32

Closed graillus closed 4 years ago

graillus commented 4 years ago

Since I upgraded from 2.0.1 to 3.0.0, I get the following error:

bin/console doctrine:migrations:migrate -n
In AbstractManagerRegistry.php line 151:

Doctrine MongoDB Manager named "default_document_manager" does not exist.

mongodb:migrations:migrate [--configuration [CONFIGURATION]] [--db-configuration [DB-CONFIGURATION]] [--dm [DM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<version>]

Looks like the bundle is tries to retrieve the default_document_manager when the command-line option --dm is not provided.

Before the upgrade, the same command with same configuration worked fine. I tested to upgrade to symfony 5, but didn't help.

Bundles installed

doesntmattr/mongodb-migrations-bundle: 3.0.0 doctrine/mongodb-odm: 2.0.5 doctrine/mongodb-odm-bundle: 4.1.1 symfony: 4.4

Bundles configuration

doesntmattr/mongodb-migrations-bundle configuration:

mongo_db_migrations:
    collection_name: 'migration_versions'
    database_name: '%env(MONGODB_DB)%'
    dir_name: '%kernel.root_dir%/Migration/'
    script_dir_name: '%kernel.root_dir%/scripts'
    name: 'MongoDB Migrations'
    namespace: 'App\Migration'

doctrine/mongodb-odm-bundle configuration:

doctrine_mongodb:
    auto_generate_proxy_classes: true
    auto_generate_hydrator_classes: true
    connections:
        default:
            server: '%env(MONGODB_URL)%'
            options: {}
    default_database: '%env(MONGODB_DB)%'
    document_managers:
        default:
            auto_mapping: true
            mappings:
                App:
                    is_bundle: false
                    type: annotation
                    dir: '%kernel.project_dir%/src/Document'
                    prefix: 'App\Document'
                    alias: App

I don't think the issue comes from my configuration, but rather from the fact that the bundle tries to get the default_document_manager document manager by default. But it doesn't exist, the default manager is named default.

IMO the bundle should not be responsible for choosing the name of the default document manager, the ManagerRegistry::getManager($name) does the job when called with null

I will open a PR to fix this behaviour

Thanks

arendjantetteroo commented 4 years ago

Caused by/changed in https://github.com/doesntmattr/mongodb-migrations-bundle/commit/73a73667941466bcca23199c144025efc9dfa111