migration-safety
Skill0 starsChanged 6 days agoMITView on GitHub
Write or review a database schema migration so it runs on a live system without downtime or data loss. Use when the user adds, renames or drops a column or table, adds an index or constraint, changes a type, backfills data, or asks "is this migration safe?".
6 other projects use a version of this.
Adopted by
Most recently taken up by
- Mehul72/skillstheir own version, first seen Nov 8, 2026
- YiftachCohen/skillstheir own version, first seen Nov 3, 2026
- itsofficialadi/boundifftheir own version, first seen Oct 25, 2026
- kapadias/nonnatheir own version, first seen Oct 1, 2026
- novatic-cu/nova-skillstheir own version, first seen Sep 20, 2026
- dennisrongo/claude-skillstheir own version, first seen Aug 16, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- dennisrongo/claude-skills★ 1same name
- Mehul72/skills★ 1same name
- novatic-cu/nova-skills★ 1same name
- YiftachCohen/skills★ 1same name
- itsofficialadi/boundiff★ 0same name
- kapadias/nonna★ 0same name
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 repository24 other files it gives its agents.
- api-docsSkill
- changelogSkill
- ci-failure-fixSkill
- code-reviewSkill
- commit-messageSkill
- competitor-analysisSkill
- data-analystSkill
- debug-detectiveSkill
- dependency-upgradeSkill
- dockerizeSkill
- email-replierSkill
- eval-promptSkill
- incident-postmortemSkill
- meeting-notesSkill
- pr-descriptionSkill
- product-specSkill
- readme-writerSkill
- refactor-safelySkill
- research-briefSkill
- security-checkSkill
- seo-articleSkill
- sql-helperSkill
- support-replySkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
5
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 23
Add NOT NULL or a foreign key to existing data: full scan under lock.
- Distinctive: line 24
Add a plain index on a big table: blocks writes.
- Distinctive: line 29
Expand: add the new column or table.
- Distinctive: line 33
Contract: stop writing the old one, wait at least one deploy, then drop it in a separate migration.
- Distinctive: line 41
Test on a copy with production-like size when you can, and time it.
- Distinctive: line 49
Run anything against production yourself.
“Common” is measured: kept by at least 6 in 10 of the 4 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
Safe database migrations
A migration is safe when every step works while old and new app versions run at the same time, and every step can be stopped or undone.
1. Gather the facts first
- Database and version (Postgres, MySQL, SQLite...), the migration tool (Prisma, Rails, Alembic, Flyway, Knex, Django...) and how migrations run in deploys (before, during or after the new code goes live).
- Table sizes and write traffic for every table touched. If you cannot see them, ask, or write the plan for "large and busy" and say so.
- Who reads and writes these columns: grep the code, background jobs, reports, other services. A column is not unused just because this repo does not mention it.
2. Classify each operation
Usually safe: add a nullable column without a volatile default, create a table, add an index concurrently (CREATE INDEX CONCURRENTLY in Postgres; ALGORITHM=INPLACE, LOCK=NONE in MySQL where supported).
Dangerous on a live table, so split it up:
- Rename or drop a column or table: old code still uses it.
- Change a column type: often rewrites the table under a lock.
- Add
NOT NULLor a foreign key to existing data: full scan under lock. In Postgres, add the constraintNOT VALID, thenVALIDATE CONSTRAINTseparately. - Add a plain index on a big table: blocks writes.
- Backfill in one
UPDATE: long transaction, lock pile-up, replication lag.
3. Use expand / contract
- Expand: add the new column or table. Nothing reads it yet.
- Dual write: deploy code that writes both old and new.
- Backfill: in batches (for example 1,000-10,000 rows per transaction, keyed by primary key), resumable, with a short pause between batches. Watch locks and replica lag.
- Switch reads to the new column. Verify counts and samples match.
- Contract: stop writing the old one, wait at least one deploy, then drop it in a separate migration.
Each step is its own migration and its own deploy. Never combine a destructive step with the code change that makes it possible.
4. Protect the database
- Set a
lock_timeout(for example 5s) andstatement_timeouton migration sessions, so a blocked migration fails fast instead of queueing every query behind it. Retry with backoff. - Migrations that cannot run inside a transaction (
CONCURRENTLY) must be marked as such in the tool. - Test on a copy with production-like size when you can, and time it.
5. Plan the rollback
For every step, write how to undo it and whether undoing loses data. A dropped column cannot be rolled back: take a backup or keep the data elsewhere first.
Do not
- Run anything against production yourself. Hand over the commands.
- Edit a migration that has already run anywhere. Write a new one.
- Claim a step is non-blocking without naming the database version where that holds.
Output
- Risk summary: each operation, lock taken, estimated impact (or "unknown: table size not given").
- The step-by-step plan with the migration files and the code change for each deploy.
- Backfill script, if any.
- Rollback for each step.
- Checks to run after each step (queries that prove it worked).
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.

