I just had this issue in a production environment: A roll-out did not go as planned, and I want to un-apply migrations applied using ./manage.py migrate. But I could not find a way to do this using the migration management command. A simplified graph of the migration used to illustrate the problem looks like this:
A, B, C are migrations that were already before the roll-out applied that I want to keep. D, E and M are the migrations that were applied during the last roll-out that I now want to un-apply. M is a merge migration without any operations.
The closest way I could find was using this sequence of operations:
-
./manage.py migrate --fake A -
./manage.py migrate --fake E -
./manage.py migrate A -
./manage.py migrate --fake C
This would un-apply migrations D and E, but not M (which in this case does not matter). I did not want to do this in our production environment, because it seemed prone to mistakes to me (the actual graph is larger and has more than 2 branches involved).
Is there a better way to do this?

