I'm trying to make SaaS application and for this purpose created multiple entity managers and corresponding connections by following official documentation but running php bin/console doctrine:migrations:diff --em=customer command results in exception The "--em" option does not exist.. I know that i can change doctrine_migrations.yaml parameter called em but that`s not a solution considering that number of entity managers can grow. Is there any workaround to go with?
doctrine.yml:
doctrine:
dbal:
default_connection: default
connections:
default:
url: '%env(resolve:DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
tenant:
url: '%env(resolve:TENANT_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
wrapper_class: App\Service\Config\Database\Connection
orm:
auto_generate_proxy_classes: true
default_entity_manager: default
entity_managers:
default:
auto_mapping: false
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
Shared:
mapping: true
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Shared'
prefix: 'App\Entity\Shared'
alias: Shared
tenant:
connection: tenant
auto_mapping: false
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
Tenant:
mapping: true
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Tenant'
prefix: 'App\Entity\Tenant'
alias: Tenant
App\Service\Config\Database\Connection class is just a wrapper that can change connection's parameters on fly.