Django Migration
Generate reproducible schema changes without manually editing migration code.
Required Context
Read AGENTS.md, docs/architecture/domain-model.md, docs/architecture/backend-implementation-contract.md, .codex/references/migration-policy.md, .codex/references/model-configuration.md, and .codex/checklists/migration-review.md.
Require an approved implementation contract and identify database ownership, target app, current migration state, and deployment constraints before running commands.
Workflow
- Run
python manage.py makemigrations <app_label>or the project-equivalent command. - Review generated operations and confirm the
Generated by Djangoprovenance header. - Run
python manage.py makemigrations --check --dry-run. - Run
python manage.py migratein the approved environment. - Run
python manage.py showmigrationsand relevant tests. - Record commands, generated filenames, results, rollout concerns, and limitations.
Hard Prohibitions
- Never create, edit, patch, format, rename, or add docstrings to migration Python files.
- Never use an empty migration to introduce handwritten
RunPythonorRunSQLlogic. - If generated operations are wrong, change the approved Model/Configuration source and regenerate safely.
- Implement approved data backfills as idempotent management commands with separate verification and rollout steps.
- Never modify a migration already applied in a shared environment.
Finish only when command provenance, pending-change checks, migration application state, and deployment risks are truthfully reported.