--- id: django-test-migrations version: "1.6.0" license: MIT license_treatment: permissive maintenance: active --- # django-test-migrations — Test django schema and data migrations, including ordering License: permissive · Maintenance: active · Downloads: 658.2K/mo ## What it is and what it does django-test-migrations is a testing library that lets you write automated tests for Django database migrations. It provides a Migrator class to apply migrations in isolation, inspect database state before and after, and verify that data is preserved correctly. It also validates migration ordering and dependencies, and detects rollback issues. The library integrates with pytest (via fixtures and markers) and unittest (via a base test case), and supports factory_boy for creating test data. You use it by applying an initial migration to set up a before-state, then applying the migration you want to test, then asserting on the resulting model structure and data. This catches bugs in complex schema or data transformations that unit tests alone won't catch. It's particularly useful when migrations modify existing data, add constraints, or change relationships—situations where silent data corruption is a real risk. Use it for: - Verify that a data migration correctly transforms existing records without loss or corruption. - Test that a schema migration can be safely rolled back and re-applied without errors. - Validate that all migrations in an app are in the correct order with correct dependencies. - Ensure a new field migration applies the correct default values to existing rows. - Confirm that a migration removing a column doesn't break dependent migrations. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Tests Django schema and data migrations, including forward/backward execution, ordering validation, and migration dependencies. Yes. If you maintain Django projects with non-trivial migrations (data transformations, schema changes, rollbacks), this package is worth installing. It has low install friction, active maintenance, no known vulnerabilities, a permissive license, and solves a real problem—catching migration bugs before production. Start with it if you're already using pytest or unittest. ## Install pip install django-test-migrations uv add django-test-migrations poetry add django-test-migrations ## Installing django-test-migrations Before you install: Low friction: pure Python wheel with a single runtime dependency (typing-extensions). Active maintenance with a release 9 days ago and 573 repository stars. License in practice: MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects. Quickstart: pip install django-test-migrations from django_test_migrations.migrator import Migrator migrator = Migrator(database='default') old_state = migrator.apply_initial_migration(('app_name', '0001_initial')) new_state = migrator.apply_tested_migration(('app_name', '0002_next')) migrator.reset() Requires Python 3.10 or later and a Django project with configured migrations (3.2, 4.1, 4.2, 5.0 officially supported; other versions likely work). Verify before relying: - Whether all advertised Django versions (3.2–6.1) are equally well-tested or if some are less stable than others. - Performance characteristics when testing large numbers of migrations or complex schema changes. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 658.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django migration testing, test django migrations, migration rollback testing, django schema migration tests, migration order validation, django data migration testing, pytest django migrations, django-testing, migration-validation, pytest-plugin [View on SkillFed](https://skillfed.io/packages/django-test-migrations) · [View on PyPI](https://pypi.org/project/django-test-migrations/)