python config_error ai_generated true

alembic.util.exc.CommandError: Multiple head revisions are present for given argument 'head'; please specify a specific target revision.

ID: python/sqlalchemy-multiple-heads-in-migration

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2025-02-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

The Alembic migration history has diverged, resulting in multiple branch heads.

generic

中文

Alembic 迁移历史发生分歧,导致有多个分支头。

Workarounds

  1. 95% success Merge the heads using alembic merge
    alembic merge heads -m "merge heads"
  2. 85% success Specify the exact revision to upgrade to
    alembic upgrade <revision_id>

Dead Ends

Common approaches that don't work:

  1. Deleting one of the migration files 80% fail

    This can break the migration chain and cause database inconsistency.

  2. Running alembic upgrade head without specifying 90% fail

    Alembic cannot determine which head to upgrade to.