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: AppServiceConfigDatabaseConnection 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: 'AppEntityShared' 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: 'AppEntityTenant' alias: Tenant
AppServiceConfigDatabaseConnection
class is just a wrapper that can change connection’s parameters on fly.
Advertisement
Answer
So far answer is: docs are outdated, doctrine/doctrine-migrations-bundle
v3.1 will probably solve it, but it relies on doctrine/migrations
library to release v3.1 (as mentioned in issue), and so far only solution is this workaround with command wrappers but it requires tweaks with configuration (YamlFile
in article expects doctrine style config and not symfony’s)