DamienHarper / auditor-bundle

The missing audit log library
MIT License
399 stars 121 forks source link

No mapping information to process when using DoctrineMigrationsBundle #398

Open Derison opened 10 months ago

Derison commented 10 months ago
Q A
auditor-bundle version 5.2.5
PHP version 8.2
Database PostgreSQL

Summary

I am trying to create a schema from the audit bundle while using multiple entity managers. This is my current configuration (simplified):

# doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
            # ...
            audit:
                driver: pdo_pgsql
                url: '%env(resolve:AUDIT_DATABASE_URL)%'

    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
            # ...
            audit:
                connection: audit
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware

doctrine_migrations_multiple_database:
    entity_managers:
        default:
            migrations_paths:
                'App\Migrations\Default': '%kernel.project_dir%/src/Migrations/Default'
        audit:
            migrations_paths:
                'App\Migrations\Audit': '%kernel.project_dir%/src/Migrations/Audit'
# dh_auditor.yaml

# Full configuration reference available at:
# https://damienharper.github.io/auditor-docs/docs/auditor-bundle/configuration/reference.html
dh_auditor:
    enabled: true
    timezone: Europe/Berlin
    role_checker: 'dh_auditor.role_checker'
    user_provider: 'dh_auditor.user_provider'
    security_provider: 'dh_auditor.security_provider'
    providers:
        doctrine:
            viewer: true
            table_prefix: null
            table_suffix: '_audit'
            ignored_columns:
            # ...

            # storage entity managers (storage services)
            storage_services:
                - '@doctrine.orm.audit_entity_manager'

            # auditing entity managers (auditing services)
            auditing_services:
                - '@doctrine.orm.default_entity_manager'

Current behavior

I am not able to create migrations with the DoctrineMigrationsBundle since the command terminates with the error message:

# bin/console d:m:diff --em=audit

In NoMappingFound.php line 13:

  No mapping information to process

doctrine:migrations:diff [--namespace NAMESPACE] [--filter-expression FILTER-EXPRESSION] [--formatted] [--line-length LINE-LENGTH] [--check-database-platform [CHECK-DATABASE-PLATFORM]] [--allow-empty-diff] [--from-empty-schema] [--em EM]

How to reproduce

Use the DoctrineMigrationsBundle in combination with the DoctrineMigrationsMultipleDatabaseBundle and configure multiple connections and entity managers. Then try to create migrations for the entity manager you've configured as storage service for the auditor bundle.

Expected behavior

Create migrations with the DoctrineMigrationsBundle.