How to revert migrations when there are multiple leaf nodes?

manage.py showmigrations shows me a list like

...
 [X] 0240_employer_data (A)
 [X] 0241_person_metadata (B)
 [ ] 0242_delete_capability_delete_collection (C)
 [X] 0242_personemployer_employerworkplace (D)
 [X] 0243_personemployer_employed_personemployer_stage (E)
 [X] 0244_remove_employerworkplace_and_more (F)

0242_delete_capability_delete_collection arrived after doing a git pull and rebase. My local branch stuff that I had been working with is 0242_personempl..0244.

I believe the graph looks like

      |
      A
      |
      B
     / \
    D   C
    |
    E
    |
    F

Because all my migrations are just in development, I'm trying to undo them to reach the same state that the main branch is at, then make them again.

I thought I could

  1. manage.py migrate myapp C
  2. delete my local D, E, F migration files files
  3. manage.py makemigrations
  4. manage.py migrate

But both manage.py migrate myapp C and manage.py migrate myapp B throw the same error:

CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0242_delete_capability_delete_collection, 0244_remove_employerworkplace_and_more in myapp).

It looks like I cannot even revert migrations while the migration graph is in this state.

What can I do to just reset my local branch's migrations and compatibilise with the main branch before building my local branch's needed migrations again? "Rebasing" the migrations in a way?

Back to Top