Some reversible migrations cannot be reversed in practice?

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Some reversible migrations cannot be reversed in practice?

I've just hit a tricky migration case, and I'd like to check I'm not missing something. The summary is that merge migrations make it possible to add migrations which cannot be unapplied, even if they are the latest migration to be run.

With the migration graph:

|      |
M2a   M2b
|      |

Now, as far as a can tell, if I want to revert M2b, I have to run `manage.py migrate app M1`. If M2a is not reversible, then it's impossible to un-apply M2b, even though the dependency graph would allow it. Or to consider another pathological case, imagine a long-running series of deployed migrations (M2a, M3a, M4a, ...) instead of an immediate merge commit; the M2b migration could be impossible to revert without reverting many other migrations in the other branch, which could delete user data if run in production.

It seems there's a missing command, `manage.py revertmigration M2b`, which would walk the dependency graph backwards to figure out which later migrations needed to be unapplied (in this case M2b and M3). Absent this command, it seems that merge migrations aren't safe to use, and should be avoided.

Am I missing something here? Appreciate any insights or workarounds anyone has on this subject.

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7093f0ed-f927-4010-988c-de93f9bd9a3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.