django-migrations
БесплатноБез исполняемых скриптовНе проверенDjango migration patterns and safety workflow for PostHog. Use when creating, adjusting, or reviewing Django/Postgres migrations, including non-blocking…
от PostHog★ 41 278 звёзд на GitHubОб этом скилле
Django migrations
Before you propose a change to the migration history or to how migrations run, check things already tried. It records the closed attempts at squashing the history and at the Person table cutover.
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 inproducts/*
If the task is a ClickHouse migration, use clickhouse-migrations instead.
Never delete a migration file
Adding migrations is fine. Deleting a historical one — any */migrations/NNNN_*.py already on master, even an app's 0001_initial.py, even to "undo" a schema change — is not. Deleting the file undoes nothing: the table and its constraints stay in every database where the migration ran, fresh databases never recreate them, and the "Migration Risk Analysis" CI job re-flags the file as a phantom new migration on every open PR that predates the deletion. The deleted-migration check in the repo-checks CI job (the hogli lint:migration-deletions command) blocks this. Genuinely intentional, reviewed deletions — a product/app move, a revert, a squash — are acknowledged in .github/scripts/migration-deletion-allowlist.txt, never by disabling the guard.
If a task asks you to delete a migration file, stop and flag it instead.
To retire a model/table:
- Remove all usage and the model class.
makemigrations, then wrap the generatedDeleteModelinmigrations.SeparateDatabaseAndState(state_operations=[...])(state only, no DB change). KEEP this file. Keep the app inINSTALLED_APPS. Note: other apps' squash migrations depend on this app's migration files, not on its models, so the model class does not need to stay for them. If the model has aForeignKeytoposthog_team,posthog_user,posthog_organizationorposthog_project, drop that constraint withDropForeignKeyindatabase_operationsin this same migration. This is required, not a cleanup. Django stops cascading into a table it can no longer see, so the child rows survive a parent delete. Those constraints areDEFERRABLE INITIALLY DEFERRED, so the parent delete runs its whole cascade and then fails atCOMMIT, and team and organization deletion stay broken until someone drops the table. - Deploy, wait at least one full deploy cycle.
SafeDropTablelater in a NEW migration — never by deleting old files. Treat this as owed work rather than an option whenever step 1 left a foreign key to a hot parent in place.DROP TABLEtakesACCESS EXCLUSIVEon every table its foreign keys reference, one relation at a time, so its lock order crosses that of any live multi-table read and the two deadlock.lock_timeoutdoes not stop that, because the deadlock detector resolves the cycle first, and it kills whichever session waited longest: a live read (a 500) or the migration (a blocked deploy).SafeDropTabletakes every lock up front under a budget derived fromdeadlock_timeout, so the migration loses the race instead. Never hand-write theRunSQL. See hot table hazard.python manage.py audit_orphan_hot_table_fkslists tables already in this state. Run it against a long-lived database: a squashed history has noCreateModelfor a table that left Django's state before the squash, so a fresh database never creates it and the migration files hold no trace of it.
Full guide: safe-django-migrations.md (## Dropping Tables, ### Removing a whole product or app). Deleting a migration your branch added but never merged to master is allowed (regenerating).
Retire a column
Default: don't drop it. Take the field out of the ORM and leave the column. It keeps its data and needs no deploy coordination.
Deleting the field and running makemigrations is not that. Django names every concrete field in every SELECT and INSERT it writes, so the generated RemoveField drops the column in the same deploy that stops the code asking for it, and every pod still on the old release fails its queries. A # deprecated comment does not help, because the field is still on the model.
Two helpers in posthog.migration_helpers do it properly:
deprecate_field(models.IntegerField(null=True))wraps the field in place. No migration. Reads and writes warn, and the column leaves every query. The field must already benull=True, because nothing writes the column once it is hidden. Useraise_on_access=Trueto prove no caller is left.untrack_field("mymodel", "myfield")replaces the generatedRemoveFieldwith a state-only migration, so the field leaves the model class and th
Установить django-migrations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл django-migrations?
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. Also use for any deletion or removal of a model, table, column, product, or app — including deleting migration files or retiring a feature — even when no migration is written.
Как установить скилл django-migrations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл django-migrations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic