feat: --check-compat Django support (v1.7.0)#96
Merged
Conversation
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.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pymaps Django operations to the existing MRT7xx patterns:RemoveField(DROP COLUMN)RenameField(RENAME COLUMN)DeleteModel/RenameModel/AlterModelTable(DROP/RENAME TABLE)AddFieldNOT NULL without a defaultMRT705 (column type change) stays Alembic-only — Django's
AlterFieldcarries the full field definition with no reference to the previous type, so a type change can't be detected statically. This is documented inpatterns.mdand the module docstring.Per-line
# noqa: MRTxxxsuppression works via the existing central loop.Changes
adapters/django_compat.py(new),check_compatwired throughanalyze_django_migrationscommands/check.pytest_django_detector.py)patterns.mdbackend-mapping table,api.md, README, roadmap, CHANGELOG; version bump to 1.7.0Verification
coverage run -m pytest)django_compat.pyat 96% coverage; total 91%ruff check+ruff format --checkclean onpytest_mrt/--check-compatemits MRT701