I''m using below versions of symfony 6.4, doctrine bundle & doctrine-migrations-bundle:
"doctrine/doctrine-bundle": "^2.11",
"doctrine/doctrine-migrations-bundle": "^3.2.2",
"doctrine/migrations": "^3.7",
"doctrine/orm": "^3.0"
My doctrine.yaml file looks like:
doctrine:
dbal:
connections:
default:
driver: 'pdo_mysql'
server_version: '8.0.36'
charset: 'UTF8'
url: '%env(resolve:DATABASE_URL)%'
logging: true
postgres:
driver: 'pdo_pgsql'
server_version: '10'
charset: 'UTF8'
url: '%env(resolve:POSTGRES_DATABASE_URL)%'
logging: true
default_connection: postgres
# url: '%env(resolve:DATABASE_URL)%'
# schema_filter: ~^(?!(Currency|table2))~
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
#server_version: '15'
# profiling_collect_backtrace: '%kernel.debug%'
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
# naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
Main:
is_bundle: false
# type: attribute
dir: '%kernel.project_dir%/src/Entity/Main'
prefix: 'App\Entity\Main'
alias: Main
postgres:
connection: postgres
# naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
mappings:
Postgres:
is_bundle: false
# type: attribute
dir: '%kernel.project_dir%/src/Entity/Postgres'
prefix: 'App\Entity\Postgres'
alias: Postgres
my doctrine_migrations.yaml file looks like:
doctrine_migrations:
em: 'default'
migrations_paths:
'DoctrineMigrations': '%kernel.project_dir%/migrations/Main'
'DoctrineMigrations\Postgres': '%kernel.project_dir%/migrations/Postgres'
storage:
table_storage:
table_name: 'doctrine_migration_versions'
version_column_name: 'version'
executed_at_column_name: 'executed_at'
execution_time_column_name: 'execution_time'
services: ~
I followed the symfony document at here. As mentioned in the document, I'm running the below commands:
php bin/console doctrine:migrations:diff --em=default
php bin/console doctrine:migrations:diff --em=postgres
But it always generates the migration files into the folder"migrations/Main". I wanted to generate the migration files into the folder "migrations/Postgres" for the option --em=postgres.
I tried to use a different doctrine_migrations.yaml file for default & postgres entity manager but it didn't work as expected.
How do the migrations as per the entity manager?