skillfed

django-linear-migrations

Ensure your migrations are linear.

django-linear-migrations v2.19.0 3.0M downloads/30d#2,778 on PyPI240
Permissive license MIT Active released

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-migrations

uv

uv add django-linear-migrations

poetry

poetry add django-linear-migrations

Installing 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

Development Status :: 5 - Production/StableFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTyping :: Typed

Tags

django migration conflict preventionlinear migration historydjango parallel migrationsmigration merge conflict detectiondjango migration orderingmax migration trackingdjango branch migration management
django-migrationsversion-control-integrationteam-development

More Software Development packages