Skip to content

feat: --check-compat Django support (v1.7.0)#96

Merged
croc100 merged 1 commit into
mainfrom
feat/django-check-compat
Jul 13, 2026
Merged

feat: --check-compat Django support (v1.7.0)#96
croc100 merged 1 commit into
mainfrom
feat/django-check-compat

Conversation

@croc100

@croc100 croc100 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

Extends mrt check --check-compat (rolling-deploy compatibility checks, MRT7xx) to Django migrations. Previously Alembic-only — the command printed a "not yet supported for Django" warning and skipped.

New pytest_mrt/adapters/django_compat.py maps Django operations to the existing MRT7xx patterns:

Code Django operation
MRT701 RemoveField (DROP COLUMN)
MRT702 RenameField (RENAME COLUMN)
MRT703 DeleteModel / RenameModel / AlterModelTable (DROP/RENAME TABLE)
MRT704 AddField NOT NULL without a default

MRT705 (column type change) stays Alembic-only — Django's AlterField carries the full field definition with no reference to the previous type, so a type change can't be detected statically. This is documented in patterns.md and the module docstring.

Per-line # noqa: MRTxxx suppression works via the existing central loop.

Changes

  • adapters/django_compat.py (new), check_compat wired through analyze_django_migrations
  • Removed the "not yet supported" warning in commands/check.py
  • 9 new tests (test_django_detector.py)
  • Docs: patterns.md backend-mapping table, api.md, README, roadmap, CHANGELOG; version bump to 1.7.0

Verification

  • 484 passed, 17 skipped locally (coverage run -m pytest)
  • django_compat.py at 96% coverage; total 91%
  • ruff check + ruff format --check clean on pytest_mrt/
  • CLI e2e confirmed: plain check emits MRT209, --check-compat emits MRT701

Rolling-deploy compatibility checks (MRT7xx) were Alembic-only. Map Django
operations to the same patterns via a new adapters/django_compat.py:

  RemoveField                              -> MRT701 (DROP COLUMN)
  RenameField                              -> MRT702 (RENAME COLUMN)
  DeleteModel / RenameModel / AlterModelTable -> MRT703 (DROP/RENAME TABLE)
  AddField NOT NULL without default        -> MRT704

MRT705 (column type change) stays Alembic-only: Django's AlterField carries
the full field definition with no reference to the previous type, so a type
change cannot be detected statically.

Wire check_compat through analyze_django_migrations; per-line noqa suppression
applies via the existing central loop. Remove the 'not yet supported for
Django' warning from the check command.

Adds 9 tests. Also drops a few unused imports flagged by ruff in adjacent
test files.

Docs: patterns.md backend mapping table, api.md, README, roadmap, CHANGELOG.
Bump version to 1.7.0.
@croc100
croc100 merged commit 0217b9a into main Jul 13, 2026
15 checks passed
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 94.44444% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pytest_mrt/adapters/django_compat.py 93.93% 2 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants