Django Migrations Inspector
django-migrations-inspector is an open source migration safety toolkit for Django.
Install the package from PyPI with:
python -m pip install django-migrations-inspector
Then add the Django app to INSTALLED_APPS with:
INSTALLED_APPS = [
# ...
"django_migration_inspector",
]
It is designed around four practical Django questions:
migration_inspect: Is the migration graph healthy or messy?migration_inspect risk: Are the pending migrations safe to deploy?migration_inspect audit: Which migration files in this repo deserve attention?migration_inspect rollback APP TARGET: If we need to reverse, what blocks us and what else gets touched?
How the commands work:
migration_inspectloads Django's migration graph and reports graph shape: heads, merge migrations, roots, leaves, and dependency hotspots. Add--offlineto read migration files without opening a database connection.migration_inspect riskasks Django for the pending forward migration plan, then checks those operations with safety rules for destructive schema changes, irreversible data code, raw SQL, unknown operations, and nested operations insideSeparateDatabaseAndState. This needs database state.migration_inspect audituses the same safety rules asrisk, but scans the migration history instead of only pending migrations. Add--offlinewhen you only want to review migration files on disk.migration_inspect rollback APP TARGETasks Django for the reverse plan to reachTARGET.TARGETcan be a full migration name, a unique prefix like0008, orzero. It checks reversibility, expected destructive reverse actions like dropping newly added tables or columns, and cross-app impact from migration dependencies, but it does not apply the rollback. This needs database state.
By default, inspect, risk, and audit ignore Django built-in apps and third-party apps.
Those reports focus on project apps that live inside your Django project tree rather than
everything installed in the environment.
rollback stays dependency-accurate instead of hiding external apps, because rollback safety can
depend on them.
The current implementation focuses on:
- Loading Django migration graphs into a typed internal model.
- Detecting merge nodes, multiple heads, root and leaf migrations, and dependency hotspots.
- Analyzing both pending deploy plans and historical migration files with rule-driven risk scoring.
- Simulating rollback plans with blockers, blast radius, cross-app impact, and reverse-step previews.
- Rendering deterministic text, JSON, Mermaid, and Graphviz DOT reports.
- Exposing a reusable
migration_inspectDjango management command.
Example usage:
python manage.py migration_inspect
python manage.py migration_inspect --offline
python manage.py migration_inspect --details
python manage.py migration_inspect risk
python manage.py migration_inspect risk --details
python manage.py migration_inspect audit
python manage.py migration_inspect audit --offline
python manage.py migration_inspect audit --details
python manage.py migration_inspect rollback billing 0001_initial
python manage.py migration_inspect rollback inventory zero
python manage.py migration_inspect rollback inventory zero --details
python manage.py migration_inspect rollback inventory 0001_initial --why-app catalog
python manage.py migration_inspect --json
python manage.py migration_inspect --format mermaid
python manage.py migration_inspect --format dot
python manage.py migration_inspect --app analytics
Replace billing, inventory, catalog, and analytics with app labels from your own Django project.
To expose the management command, add "django_migration_inspector" to INSTALLED_APPS.
For hosted project documentation, this repository includes an MkDocs site that can be published on
GitHub Pages or Read the Docs.
Local docs commands:
python -m pip install '.[docs]'
mkdocs serve
mkdocs build --strict
Local quality commands:
python -m pip install -e '.[dev,docs]'
ruff format .
ruff format --check .
ruff check .
mypy src tests
pytest -q
Release files for django-migrations-inspector 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_migrations_inspector-0.1.0.tar.gz | 53.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_migrations_inspector-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 110.8 kB
Release files / django_migrations_inspector-0.1.0.tar.gz
| Download URL | django_migrations_inspector-0.1.0.tar.gz |
|---|---|
| Size | 53.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
544bcd866113c5ad4f661f9da1a7641ffae9ecb012a47e0ab99c2c874273edd2
|
|
BLAKE2b-256 checksum How to use checksums |
772cc0d8b8e212baaa68c081eee116e3776618a9cd7f2b75698247fd5531dee1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency logRelease files / django_migrations_inspector-0.1.0-py3-none-any.whl
| Download URL | django_migrations_inspector-0.1.0-py3-none-any.whl |
|---|---|
| Size | 57.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb30a9490221d1597c55e745d4f2ef3abd19639de219b7cbb3e13ff71d1004de
|
|
BLAKE2b-256 checksum How to use checksums |
1789b522f77363a84c36fa5df1f95a3170ffcfd8925883d8dec3021b3b01a53c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency log