django-migrations

django-migrations is a skill for Claude Code, Codex from PostHog/posthog-foss. It costs 99 tokens per session (4,724 once invoked), scanned A, original, MIT.

A workflow for changing Django migrations, which are versioned instructions that update a PostgreSQL database's structure. It covers safe schema changes, data backfills, migration conflicts, and moving Django models between products.

In plain words
What is it for?
Use it when creating, reviewing, or adjusting indexes, constraints, tables, model moves, backfills, and conflicting Django migration files.
Why use it?
It helps avoid locking tables, losing data, or breaking databases that already ran an older migration. It also explains how to resolve conflicts without deleting migration history.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit Use it when creating, reviewing, or adjusting indexes, constraints, tables, model moves, backfills, and conflicting Django migration files.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/posthog/posthog-foss/django-migrations
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add PostHog/posthog-foss --skill django-migrations
Clone the repo
git clone --depth 1 https://github.com/PostHog/posthog-foss

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for django-migrations

README.md
[![agentmods](https://agentmods.dev/badge/skills/posthog/posthog-foss/django-migrations/github.svg)](https://agentmods.dev/skills/posthog/posthog-foss/django-migrations)
Your own site
<a href="https://agentmods.dev/skills/posthog/posthog-foss/django-migrations"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/django-migrations/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for django-migrations

Your own site · 80×15
<a href="https://agentmods.dev/skills/posthog/posthog-foss/django-migrations"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/django-migrations.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,724 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00099 $0.04724
Opus 5.5 $0.00040 $0.01890
Sonnet 5.5 $0.00020 $0.00945
Haiku 4.5 $0.00010 $0.00472

Measured 10d ago against content hash 407943407c77, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

django-migrations scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/django-migrations/SKILL.md · 171 lines

How it starts

The opening of the file, as written. The whole thing — 171 lines — stays where its author put it; the contents beside it link to each section on 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.md
  • docs/published/handbook/engineering/databases/schema-changes.md
  • products/README.md (## Adding or moving backend models and migrations) when working in products/*

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:

  1. Remove all usage and the model class. makemigrations, then wrap the generated DeleteModel in migrations.SeparateDatabaseAndState(state_operations=[...]) (state only, no DB change). KEEP this file. Keep the app in INSTALLED_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 a ForeignKey to posthog_team, posthog_user, posthog_organization or posthog_project, drop that constraint with DropForeignKey in database_operations in 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 are DEFERRABLE INITIALLY DEFERRED, so the parent delete runs its whole cascade and then fails at COMMIT, and team and organization deletion stay broken until someone drops the table.
  2. Deploy, wait at least one full deploy cycle.
  3. SafeDropTable later 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 TABLE takes ACCESS EXCLUSIVE on 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_timeout does 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). SafeDropTable takes every lock up front under a budget derived from deadlock_timeout, so the migration loses the race instead. Never hand-write the RunSQL. See hot table hazard. python manage.py audit_orphan_hot_table_fks lists tables already in this state. Run it against a long-lived database: a squashed history has no CreateModel for 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.

Read the full file on GitHub · 171 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago Changed 407943407c77
  2. 16d ago Changed · +10 lines d86555389677
  3. 21d ago Changed · +1 lines 56bc4d7e1db7
  4. 23d ago Changed · -14 lines 899dbbed504e
  5. 1mo ago Changed · +1 lines 6aab7e2afbc2
  6. 2mo ago Changed 557a1e64ead2
  7. 2mo ago Changed · +1 lines 6839c4fbb9fe
  8. 2mo ago Changed 3fe42a4cae39
  9. 2mo ago Changed · +1 lines 999c509bf48a
  10. 2mo ago First seen · 171 lines · 99 tokens per session scan A ea7cecc1f29c

Subscribe to this mod's changes

django-migrations is a skill published in the GitHub repository PostHog/posthog-foss (736 stars, last pushed today), licensed MIT. It adds 99 tokens to every session and 4,724 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

django-migrations compared with skills from other repositories

django-migrations next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
django-migrationsPostHog/posthog-fossSkill736todayMITA99Claude Code, Codex
alloydb-basicsgoogle/skillsSkill26ktodayApache-2.0A72Claude Code, Codex
postgresql-table-designwshobson/agentsSkill43k2d agoMITA37Claude Code
db-repairgarrytan/gbrainSkill34ktodayMITA96Claude Code
volcengine-rds-postgresqlbytedance/agentkit-samplesSkill496yesterdayApache-2.0A63Claude Code, Codex
dsqlawslabs/agent-pluginsSkill957yesterdayApache-2.0A247Claude Code
postgresdbericrisco/rsc-harnessSkill7072d agoMITA91Claude Code, Codex