Django migration patterns and safety workflow for PostHog. Use when creating, adjusting, or reviewing Django/Postgres migrations, including non-blocking index/constraint changes, multi-phase schema changes, data backfills, migration conflict rebasing, and product model moves that require SeparateDatabaseAndState.
Read these files first, before writing or editing a migration:
docs/published/handbook/engineering/developing-locally.md (## Django migrations, ### Non-blocking migrations, ### Resolving merge conflicts)docs/published/handbook/engineering/safe-django-migrations.mddocs/published/handbook/engineering/databases/schema-changes.mdproducts/README.md (## Adding or moving backend models and migrations) when working in products/*If the task is a ClickHouse migration, use clickhouse-migrations instead.
NOT NULL, indexes, constraints, large data updates, model moves).DEBUG=1 ./manage.py makemigrations [app_label].
For merge conflicts: python manage.py rebase_migration <app> && git add <app>/migrations (posthog or ee).safe-django-migrations.md — the doc covers multi-phase rollouts, SeparateDatabaseAndState, concurrent operations, idempotency, and all risky patterns in detail../manage.py sqlmigrate <app> <migration_number>, run tests, confirm linear migration sequence.