# alembic.util.exc.CommandError: 给定参数 'head' 存在多个头修订版本；请指定一个特定的目标修订版本。

- **ID:** `python/sqlalchemy-multiple-heads-in-migration`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Merge the heads using alembic merge** (95% 成功率)
   ```
   alembic merge heads -m "merge heads"
   ```
2. **Specify the exact revision to upgrade to** (85% 成功率)
   ```
   alembic upgrade <revision_id>
   ```

## 无效尝试

- **Deleting one of the migration files** — This can break the migration chain and cause database inconsistency. (80% 失败率)
- **Running alembic upgrade head without specifying** — Alembic cannot determine which head to upgrade to. (90% 失败率)
