Skip to content
Latchkey

Django "Conflicting migrations detected" - Merge Branches

Two migrations in the same app share the same parent, leaving the migration graph with more than one leaf. Django cannot pick a single linear path until you add a merge migration that joins them.

What this error means

migrate or makemigrations --check fails reporting conflicting migrations / multiple leaf nodes for an app. It appears after two branches each created a migration on top of the same previous one and both merged.

Django output
CommandError: Conflicting migrations detected; multiple leaf nodes in the
migration graph: (0007_a, 0007_b in orders).
To fix them run 'python manage.py makemigrations --merge'

Common causes

Two branches forked the same parent migration

Each branch ran makemigrations on top of, say, 0006, producing two 0007_* leaves. Merging both branches leaves the app with two leaf nodes.

No merge migration created

A fork is legitimate, but Django needs an explicit merge migration to rejoin the two leaves into a single linear head.

How to fix it

Create a merge migration

Let Django generate a migration that depends on both leaves, rejoining the graph.

Terminal
python manage.py makemigrations --merge
git add orders/migrations/0008_merge_*.py

Or rebase one migration onto the other

  1. Edit one branch’s migration dependencies to point at the other branch’s leaf.
  2. This linearizes the graph into a single chain with one leaf.
  3. Prefer the merge migration when both branches are already shared.

How to prevent it

  • Run makemigrations --check in CI so multiple leaves are caught early.
  • Rebase/merge migration branches before merging feature branches.
  • Coordinate so two branches don’t fork the same parent migration unnoticed.

Frequently asked questions

What causes ""Conflicting migrations detected""?
Each branch ran makemigrations on top of, say, 0006, producing two 0007_* leaves. Merging both branches leaves the app with two leaf nodes.
How do I fix "Conflicting migrations detected"?
Let Django generate a migration that depends on both leaves, rejoining the graph.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card