What I want to do : For every migrations executed with php bin/console doctrine:migrations:migrate
to be wrapped in a proper transaction (START TRANSACTION / BEGIN / ROLLBACK / ...).
My config/doctrine_migrations.yml file contains the following options :
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/migrations'
enable_profiler: false
# Run all migrations in a transaction.
all_or_nothing: true
# Adds an extra check in the generated migrations to ensure that is executed on the same database type.
check_database_platform: true
# Whether to wrap migrations in a single transaction.
transactional: true
And in any case the isTransactional method from AbstractMigration returns true by default.
Am I missing something here ? Does "transactions" here have another meaning than what's I'm expecting ?
I'm running symfony 6.3.7
with doctine-migrations-bundle 3.2.4
on a 5.7.29 MySQL database
Well it turns out the transactions are being set as expected but MySQL autocommits when executing a DDL statement (CREATE / ALTER TABLE / ...), so as soon as a DDL statement is run in a migration file, the transaction is commited and the transactionnal mode is turned off and there is no rollback to the previous state.