Doctrine migration up vs postUp
We are using Doctrine Migrations to update our table structure with changes that are needed when we implement new code.
This week we ran into an issue where data migration failed in the
postUp part of a certain migration. When we retried the migration, it failed on the
up part since that part was executed successfully. We needed to SSH in the kubernetes pod in order to manually perform the down migration and retry it again, which was a bit annoying.
Based on this, we learned that if there's a failure in the
postUp, doctrine won't roll-back the changes done in the
up function. This makes sense, but forces you to really think about where in your migration queries can fail and how this should be resolved if this happens.
This ultimately resulted for us into moving all migration logic from
postUp back to the
up function to have doctrine be able to do a full rollback if in one step something goes wrong in stead of having to manually execute a down migration before being able to perform the up again.