db-migration
Skill2 starsChanged 5 months agoMITView on GitHub
Expand/contract pattern for zero-downtime database schema changes. Replaces the (wrong) \"forward-only by default\" rule. The four-phase pattern: expand → backfill → cutover → contract.
24 other projects use a version of this.
Adopted by
Most recently taken up by
- ricci-labs/twisetheir own version, first seen Nov 8, 2026
- aniketshukla1/sdlc-kittheir own version, first seen Nov 8, 2026
- globalmpc/backendskillstheir own version, first seen Nov 8, 2026
- F3-Nation/f3-nationtheir own version, first seen Nov 2, 2026
- andidev30/the-artifacttheir own version, first seen Oct 20, 2026
- lepresk/groundworktheir own version, first seen Oct 15, 2026
Used with
Projects with it also use api-endpoint, write-tests and 4 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
tadoEngSkillapi-endpoint
Add or change a backend API endpoint on this product, keeping Pydantic as the single contract authority and regenerating the TypeScript client. Use when asked to add an endpoint, expose data to the frontend, change a request or response shape, or wire a new backend capability into a page.
Also in 4 projects that use this
SentrySkillwrite-tests
Write tests following project conventions. Use when adding new tests or modifying existing ones.
Also in 3 projects that use this
Microsoft AzureSkillgit-workflow
Squad branching model: dev-first workflow with insiders preview channel
Also in 3 projects that use this
Microsoft AzureSkilldesign
Design rules and conventions for the API Center Portal. Use when editing detail pages, card components, badges, layout, navigation, sidebars, or headers. Covers badge styling, metadata placement, page navigation patterns, and layout alignment.
Also in 3 projects that use this
VercelSkillagent-browser
Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.
Also in 3 projects that use this
MicrosoftSkillrelease
Use ONLY when the user explicitly asks to cut/publish a Huabu desktop release or tag a version. Performs an outward action — bumps the version in apps/desktop/package.json, commits + annotated-tags vX.Y.Z, and pushes the branch + tag. That tag push auto-builds the macOS/Windows installers and publishes a GitHub Release. Provides `status`, `bump`, `tag-push`, and a one-command `run` (bump → tag-push).
Also in 3 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- dipu-bd/lightnovel-crawler★ 2.6ksame name
- lncrawl/lightnovel-crawler★ 2.6ksame name
- openmeterio/openmeter★ 2.4ksame name
- F3-Nation/f3-nation★ 210same name
- hiromaily/go-crypto-wallet★ 128same name
- nrjdalal/zerostarter★ 65same name
- xin-lai/CodeSpirit★ 56same name
- globalmpc/backendskills★ 44same name
- NicholasFlemmer/styx-app★ 31same name
- nikandr-surkov/ai-saas-starter★ 16same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository60 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- analyzeSkill
- animation-disciplineSkill
- api-versioningSkill
- autopilotSkill
- browser-e2eSkill
- characterizeSkill
- clarifySkill
- codemodSkill
- constitution-compactSkill
- constitutionSkill
- context-budgetSkill
- creative-webSkill
- debugSkill
- detect-stackSkill
- dispatch-criteriaSkill
- dreamSkill
- experimentSkill
- fastapiSkill
- flag-cleanupSkill
- flag-rolloutSkill
- flask-realtimeSkill
- framework-detectorSkill
- front-end-designSkill
- grill-meSkill
- handoffSkill
- image-generationSkill
- implementSkill
- initiativeSkill
- instinctSkill
- loopSkill
- nextjsSkill
- observabilitySkill
- okr-alignSkill
- parallel-swarmSkill
- pivotSkill
- planSkill
- pr-bodySkill
- prime-disciplineSkill
- prod-observabilitySkill
- react-nodeSkill
- react-viteSkill
- release-trainSkill
- researchSkill
- reviewSkill
- security-guardSkill
- self-healSkill
- shipSkill
- skill-creatorSkill
- specifySkill
- tailwind-disciplineSkill
- tasksSkill
- tdd-loopSkill
- token-budgetSkill
- typographySkill
- verify-loopSkill
- verifySkill
- wip-checkpointSkill
- <kebab-case-skill-name>Skill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 21 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 74
Long-running migrations: use lock_timeout and statement_timeout to avoid blocking pile-ups.
“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DB Migration — Expand / Contract
Zero-downtime schema changes require the four-phase pattern. A single "forward-only migration" deploy is wrong for any non-trivial change at scale.
The four phases
Phase A — EXPAND
- Add new schema element (column, table, index) — additive only
- Old code continues to work (it doesn't see the new element)
- Deploy and verify no errors
Phase B — DUAL-WRITE / BACKFILL
- New code writes to BOTH old and new (dual-write)
- Backfill historical data into the new element (batched, off-peak)
- Old code still reads the old element
Phase C — CUTOVER (read switch)
- New code reads from the new element
- Old code still writes the old element
- Monitor for divergence; verify the read path is correct
Phase D — CONTRACT
- Remove dual-write; new code writes only the new element
- Drop the old element (column / table) — separate deploy
- Update the schema docsPer-change patterns
Add a column
- A:
ALTER TABLE x ADD COLUMN new_col TYPE NULL(NULL allowed; no default to avoid table rewrite on big tables) - B: write to both old and new (if replacing); or just start using new
- C: read from new
- D: drop old (if applicable)
Rename a column
- A:
ALTER TABLE x ADD COLUMN new_name TYPE(add new) - B: dual-write old + new; backfill (UPDATE x SET new_name = old_name in batches)
- C: read switches to new
- D: drop old, rename if desired (
ALTER COLUMN ... RENAMEif portable)
Change a column type
- A: add new typed column (
alter table x add column new_col NEW_TYPE) - B: dual-write with conversion; backfill
- C: read from new
- D: drop old
Split a table
- A: create new tables
- B: dual-write to new tables; backfill
- C: read switches to new tables
- D: drop old table
Drop a column
- A: stop reading from it (code change first)
- B: stop writing to it (next deploy)
- C: verify no references
- D: drop the column
Per-DB specifics
Postgres
ALTER TABLE ADD COLUMNis fast IF no default + NULL allowed. AvoidNOT NULL DEFAULT 'x'on big tables — it rewrites.- Concurrent indexes:
CREATE INDEX CONCURRENTLY— doesn't block writes. - Long-running migrations: use
lock_timeoutandstatement_timeoutto avoid blocking pile-ups. - Backfill:
UPDATE ... WHERE id BETWEEN N AND N+1000in batches; commit per batch.
MySQL
pt-online-schema-changefor big tables (Percona toolkit).gh-ostfor low-impact schema changes (GitHub's tool).- Native
ALGORITHM=INPLACE, LOCK=NONEavailable for some changes in MySQL 8.
Aurora / DynamoDB / Mongo / etc.
- Apply the same expand/contract logic; the primitives differ.
CI gates
- Migration files require a corresponding reverse migration OR explicit "no-rollback; data-loss" tag
- Migrations touching large tables (>100k rows) require
CONCURRENTLYor pt-osc/gh-ost - Phase-A and Phase-D are separate PRs (don't combine; each deploys independently)
- Spec's Rollout section lists the four phases with target ship dates
Hard rules
- Never combine phases in one deploy. Each phase is a separate code change + deploy + verify cycle.
- Always have a reverse migration for Phase A and Phase D (Phase B/C are code-only).
- Backfill in batches. Big single-transaction backfills lock tables.
- Monitor during cutover. Watch the read/write divergence at Phase C.
- Document. Each migration touches an ADR explaining why.
References
- Square Engineering — "Zero downtime migrations" (canonical)
- Stripe — "Online schema migrations" blog series
- gh-ost README — https://github.com/github/gh-ost
- See also:
/upgradecommand,.claude/rules/backend.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

