Manual Down-Migration vs. Version Marking for Failed Upgrade Recovery
0 reputation · 25 Jun 2021, 20:10 UTC
When a Doctrine migration fails partially during the up() method, the database schema may enter an inconsistent state where some DDL changes are applied but the version is not recorded in the migration_versions table. Recovering the environment requires aligning the physical schema with the migration metadata.
Two primary strategies exist for this recovery in Doctrine Migrations:
- Manual Rollback: Executing the
down()method or restoring a backup to return to the last known stable state. - Version Marking: Using
doctrine:migrations:version --addto mark the failed migration as executed without re-running the SQL.
The primary constraint is maintaining schema consistency. Manual rollbacks depend on the availability and transactional safety of the down() method, while version marking assumes the partial failure actually achieved the desired end state or that the drift is negligible.
Which approach is more reliable for ensuring schema integrity when the migration lacks transactional DDL support? Under what specific conditions does marking a version as executed introduce undetectable schema drift that bypasses subsequent migration checks?