django-linear-migrations
Ensure your migrations are linear.
What it is and what it does
django-linear-migrations is a Django app that prevents migration history conflicts when multiple branches develop migrations in parallel. It works by having makemigrations and squashmigrations record the latest migration name in per-app max_migration.txt files; these files create merge conflicts in Git (or other version control) when parallel migrations are attempted, forcing developers to resolve the conflict before merging rather than discovering the problem later during deployment.
The package includes management commands to initialize max_migration.txt files, detect and report migration conflicts via system checks, and automatically rebase migrations after Git conflicts are resolved. It requires minimal setup beyond adding the app to INSTALLED_APPS and running create_max_migration_files, though projects with custom makemigrations or squashmigrations commands must ensure those commands subclass django-linear-migrations' Command class.
Use it for:
- Prevent out-of-order migration execution in teams where multiple feature branches create migrations simultaneously.
- Detect migration conflicts early via version control merge conflicts rather than discovering them during deployment.
- Automatically rebase a conflicted migration to depend on the new migration from the main branch using rebase_migration.
- Validate migration linearity across all first-party apps with built-in system checks (dlm.E001 through dlm.E005).
- Manage migration history in projects with many first-party apps by tracking max migration per app.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Enforces linear migration history in Django projects by tracking the latest migration per app in max_migration.txt files, preventing merge conflicts and out-of-order migration execution.
Yes. django-linear-migrations solves a real problem in team Django development—parallel migrations causing out-of-order execution—with low install friction, active maintenance, no known vulnerabilities, and a permissive MIT license. Install it if your team works on multiple branches simultaneously; the setup cost is minimal and the conflict-detection benefit is substantial.
Install
django-linear-migrations on PyPI
pip
pip install django-linear-migrationsuv
uv add django-linear-migrationspoetry
poetry add django-linear-migrationsInstalling django-linear-migrations
Before you install
Low install friction with a single django dependency. Active maintenance with recent releases; last commit 2026-08-13 and 240 repository stars indicate ongoing support.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal restrictions, making it suitable for both open-source and proprietary Django projects.
Quickstart
pip install django-linear-migrations
# Add to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...,
"django_linear_migrations",
...,
]
# Create max_migration.txt files:
python manage.py create_max_migration_files
Requires Django 4.2 to 6.0 and Python 3.9 to 3.14; automatic first-party app detection may fail on editable packages, requiring manual FIRST_PARTY_APPS configuration.
Verify before relying
- Whether the rebase_migration command's automatic conflict resolution works reliably across all Git workflows and edge cases.
- Performance impact when managing max_migration.txt files across projects with many first-party apps.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — django |
| Maintenance | actively maintained — 330 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,035,508/month — #2,778 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_linear_migrations-2.19.0-py3-none-any.whl
Keywords: Django
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
django-migration-linterAnalyzes Django migrations to detect…
permissive · top 5,000 on PyPI
django-pgmigratePrevents migration downtime by detecting and…
permissive · top 5,000 on PyPI
django-safemigrateAdds a safemigrate command to Django that…
permissive · top 15,000 on PyPI
django-syzygyAutomates Django database migration deployment…
permissive · top 15,000 on PyPI
django-test-migrationsTests Django schema and data migrations,…
permissive · top 15,000 on PyPI
django-add-default-valueProvides a Django migration operation to set…
permissive · top 15,000 on PyPI
django-pg-zero-downtime-migrationsProvides a Django database backend for…
permissive · top 15,000 on PyPI
peewee-migratePeewee Migrate provides a command-line and…
permissive · top 15,000 on PyPI
ghstackghstack submits stacks of local Git commits to…
permissive · top 15,000 on PyPI