Julien Danjou 4/14/2026

Fixing Alembic's Multiple Heads Problem with Git

Read Original

This article addresses the common Alembic migration conflict where multiple developers create migrations in parallel, resulting in multiple heads. It explains how Alembic's revision/down_revision chain works and why parallel branches break it. The author shares how their team at Mergify built an open-source library, alembic-git-revisions, that uses Git's commit history to automatically determine the correct migration order, eliminating manual fixes and merge conflicts. The solution leverages git log to track file addition order on main, making it compatible with squash merges, rebases, and regular merges. The article is a technical tutorial focused on DevOps, database migrations, and Python tooling.

Fixing Alembic's Multiple Heads Problem with Git

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet