Skip to main content

django-modern-migration-fixer

CI

Fix conflicting Django migrations (numbered styles) using plain git CLI, with robust support for normal repos and git worktrees. No GitPython dependency.

This is a fork and drop-in replacement for django-migration-fixer which is not actively maintained by the author.

  • Detects conflicting leaf nodes and renumbers local migrations to form a single linear chain.
  • Rewrites dependencies to point to the last migration on the default branch.
  • Works in git worktrees by discovering the repo root via git rev-parse --show-toplevel.

Install

uv pip install django-modern-migration-fixer

Add to your Django settings:

INSTALLED_APPS = [
    # ...
    "django_modern_migration_fixer",
    # ...
]

Usage

./manage.py makemigrations --fix [apps...]

Useful flags:

  • -b, --default-branch: Name of the default branch (default: master).
  • -r, --remote: Git remote (default: origin).
  • -s, --skip-default-branch-update: Skip fetching remote default branch.
  • -f, --force-update: Force update the default branch refs before fixing.

Examples:

./manage.py makemigrations --fix
./manage.py makemigrations --fix -b master --skip-default-branch-update
./manage.py makemigrations --fix -r upstream --force-update

How it works

  • On a Conflicting migrations error, the command:
    • Verifies the repo is clean.
    • Optionally fetches the default branch.
    • Resolves default-branch and HEAD SHAs robustly.
    • Loads the migration graph and finds conflicts per app.
    • Filters changed migration files under the app’s migration folder between default SHA and HEAD.
    • Renumbers local files and rewrites dependencies to form a single chain.

Limitations

  • Only supports numbered migration file names (e.g., 0001_initial). Non-numbered names fail fast with a clear message.
  • Cross-app dependency rewrites beyond simple renumbering are out of scope.

Make targets

Convenient shortcuts are available via make:

  • make tests — Run unit and e2e tests (unittest discovery).
  • make tests-unit — Discover and run tests under tests/unit.
  • make tests-e2e — Discover and run tests under tests/e2e (safe if empty).
  • make build — uv sync --extra dev then uv build to produce wheels/sdist.
  • make distribute — twine check then upload artifacts in dist/ to PyPI.

Notes:

  • Test runs set PYTHONPATH=src so the package imports without installation.
  • build and distribute require uv to be installed and available on PATH.

License

MIT

Metadata

Release files for django-modern-migration-fixer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-modern-migration-fixer 0.1.2
File Size Uploaded
django_modern_migration_fixer-0.1.2.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-modern-migration-fixer 0.1.2
File Interpreter ABI Platform
django_modern_migration_fixer-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / django_modern_migration_fixer-0.1.2.tar.gz

Download URL django_modern_migration_fixer-0.1.2.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
bbd49092baa7d4641328df8a10588a428b961de0ca687b4e5d82e80acb2bb328
BLAKE2b-256 checksum
How to use checksums
4a57b81a196198ed1893c18349dffcc0785572d594233d6ceda43774eed9f01d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / django_modern_migration_fixer-0.1.2-py3-none-any.whl

Download URL django_modern_migration_fixer-0.1.2-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9faf26379cabe5f230869ee5205e640d90bf53a5d66b71d87c3b45ef4dab22c7
BLAKE2b-256 checksum
How to use checksums
e2e842f3c8f3155353e0349817609af7a9c43128f74985b5a5cd4769174f947b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page