Instead of using only sqllite in dev, you can create a dev/doctrine.yml
file that declares three entity managers (one per database engine) as described in documentation. Of course, you only do it in development file. Don't alter your production configuration file.
Then, you create an env variable to specify the default orm to use in dev:
# config/packages/dev/doctrine.yaml
doctrine:
orm:
default_entity_manager: '%env(my_current_orm)%'
# ...
At this step, you are now able to change database server/engine only by changing an environment variable.
Based on this answer, you can create one doctrine_migration.yaml
file per database engine. In these files, you specify different subdirectories to store your migrations files.
#example for mssql engine
doctrine_migrations:
dir_name: '%kernel.project_dir%/migrations/mssql'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations/MsSql/
At this step, you are now able to launch migration commands for each database engine.
symfony console doctrine:migrations:status --em=mssql \
--configuration=src/config/packages/dev/migrations/mssql.yml
As you see, for migration, I did not use the environment variable. I manually specify the default orm --em=xxxx
and I specify the configuration file. I used this in an old project, but I think that it's now possible to use the environment variable in the doctrine_migration.yaml
file to optimize configuration and have only one file.
edit:(I remember that I have updated the module loader to avoid to load multiple times the migrations config files, you perhaps have to move the non-sqlite doctrine_migration configuration files in another directory than the usual one)