- Home
- Skills
- APIs & Backend
- Zero-Downtime Django Migrations
More screenshots
Works with the AI Agents you already use
Zero-Downtime Django Migrations
Ship Django + PostgreSQL migrations without locking prod: timeouts, concurrent indexes, expand/contract, batched backfills.
Free
Zero-Downtime Django Migrations
Example session with this skill installed
Add a NOT NULL status column with a default to our 80M-row orders table and index it. How do we ship this without downtime?
- Read your context and instructions
- Compiled the zero-downtime django migrations
Summary
Ship it in three releases. A single AddField(null=False, default=...) plus a normal AddIndex would take heavy locks on a hot table. Example output; names are illustrative.
Plan
| Release | Migration | Why it is safe |
|---|---|---|
| 1. Expand | AddField(status, null=True) with no default | Metadata-only, no table rewrite |
| 1. Expand | App code starts writing status on every save | Old rows are still NULL, which is fine |
| 2. Backfill | RunPython in batches of 5,000 ids, one transaction per batch | No long transaction, replicas keep up |
| 2. Index | AddIndexConcurrently in a non-atomic migration | Builds without blocking writes |
| 3. Contract | CHECK (status IS NOT NULL) NOT VALID, then VALIDATE CONSTRAINT, then SET NOT NULL | Validation takes a weak lock, SET NOT NULL skips the scan |
Guard rails on every migration
class Migration(TimeoutAwareMigration):
lock_timeout = timedelta(seconds=15)
statement_timeout = timedelta(seconds=20)
Next steps
- Run the migration linter (
--fix) on the generated files. - Deploy release 1 and wait for old pods to drain before release 2.
- Confirm zero NULLs before adding the constraint in release 3.
Connects securely to your tools. The creator never sees your data.
About this skill
Never take production down with a migration again
Migrations run before the new code rolls out, so for a few minutes old code talks to the new schema. This skill teaches your agent to write Django and PostgreSQL migrations that survive that window: no long locks, no table rewrites, nothing the running code still needs gets removed.
How it helps
- No surprise outages. Every migration gets a lock timeout and a statement timeout, so it fails fast instead of blocking traffic.
- Safe indexes and constraints. Concurrent index creation, and NOT VALID then VALIDATE for new constraints.
- Safe multi-release changes. Expand, migrate, contract: split risky changes across releases so old and new code both keep working.
- Safe backfills. Batched data migrations that don't hold a transaction open on a hot table.
- Fewer review debates. A per-operation lock reference and checklists tell reviewers what is safe and what is not.
What's inside
A short SKILL.md with the two golden rules and the migration toolkit pattern, plus 4 reference guides: Postgres locks, indexes, columns/keys/constraints, and data backfills and deployment.
Use it when
Adding or changing columns, indexes, constraints or foreign keys, writing RunPython/RunSQL backfills, reviewing makemigrations output, or setting up migration safety in a new Django service.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 1 day ago
- Free to download with an account