database-migration-safety
Skill4 starsChanged 8 months agoMITArchived repositoryView on GitHub
Auto-load when: working with Alembic, raw SQL migrations, schema changes, migrations/ directory, or *.sql files. Triggers on alembic, migration, upgrade, downgrade, schema, ALTER TABLE (≥2 keywords). Every migration must satisfy these requirements before alembic upgrade head runs: Before proposing or executing any migration: --autogenerate misses the following — always check manually: - Table/column renames (it generates DROP + ADD instead) - server_default changes - Check constraints (CheckConstraint) - Partial indexes - Custom types Safe pattern for removing a column: -…
1 other project uses a version of this.
Adopted by
Most recently taken up by
- cvsz/zomegatheir own version, first seen Sep 2, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- cvsz/zomega★ 1same 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 repository23 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- claude-api-patternsSkill
- critical-analysisSkill
- data-validationSkill
- design-doc-creatorSkill
- experiment-trackingSkill
- fastapi-patternsSkill
- github-actionsSkill
- htmx-frontendSkill
- infra-yandex-cloudSkill
- langgraph-patternsSkill
- ml-data-handlingSkill
- multimodal-routerSkill
- nlp-slm-patternsSkill
- predictive-analyticsSkill
- prompt-engineeringSkill
- python-project-standardsSkill
- rag-vector-dbSkill
- skill-developerSkill
- supply-chain-auditorSkill
- test-first-patternsSkill
- windows-developerSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
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 9
Every migration must satisfy these requirements before alembic upgrade head runs:
- Distinctive: line 18
Before proposing or executing any migration:
- Distinctive: line 56
When this skill is active, append to analysis:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: Database Migration Safety
When to Load
Auto-load when: working with Alembic, raw SQL migrations, schema changes, migrations/ directory, or *.sql files. Triggers on alembic, migration, upgrade, downgrade, schema, ALTER TABLE (≥2 keywords).
Core Rules
Every migration must satisfy these requirements before alembic upgrade head runs:
- Reversible —
downgrade()must be implemented and tested.passis not acceptable. - Staged — run against a staging/dev database before production.
- Piloted — for data migrations over 1M rows, run on a 1% sample first.
- Snapshotted — take a DB snapshot/backup before any destructive operation (DROP, ALTER with data loss risk).
Pre-Migration Checklist
Before proposing or executing any migration:
[ ] downgrade() is implemented (not pass)
[ ] Migration tested on staging DB
[ ] For tables > 100k rows: migration is non-locking (CONCURRENT index, batched updates)
[ ] No data loss without explicit acknowledgment: DROP COLUMN, TRUNCATE, type narrowing
[ ] --autogenerate output reviewed manually (it misses: renames, indexes, check constraints)
[ ] Rollback plan documented: "If this fails in prod, run: alembic downgrade -1"Anti-Patterns — Block on Detection
| Anti-Pattern | Risk | Required Action |
downgrade() is pass | Irreversible migration | Implement downgrade or get explicit sign-off |
DROP COLUMN without nullable grace period | Data loss on rollback | Add nullable=True first, drop in next release |
--autogenerate applied without review | Silent schema drift | Always diff before apply |
alembic upgrade head in prod without staging | Broken prod schema | Require staging run first |
Locking ALTER TABLE on large table | Table lock, downtime | Use CREATE INDEX CONCURRENTLY, batched UPDATE |
| Migration touches multiple unrelated models | Hard to rollback atomically | Split into separate migrations |
Alembic-Specific Guidance
--autogenerate misses the following — always check manually:
- Table/column renames (it generates DROP + ADD instead)
server_defaultchanges- Check constraints (
CheckConstraint) - Partial indexes
- Custom types
Safe pattern for removing a column:
- Migration N:
nullable=True, remove from ORM model - Deploy N, verify no writes
- Migration N+1:
DROP COLUMN
Quick Mode Format
When this skill is active, append to analysis:
[MigSafety]: BLOCK|WARN|CLEAR — [specific risk identified] -> [required action]Examples:
[MigSafety]: BLOCK — downgrade() is pass on 2M-row table -> implement downgrade or get explicit sign-off[MigSafety]: WARN — no staging run documented -> confirm staging test before prod apply[MigSafety]: CLEAR — evaluated: downgrade implemented, staging confirmed, no locking ops
When NOT to Flag
- Simple
ADD COLUMN NOT NULL DEFAULTon small tables (< 10k rows) — low risk - Adding new tables only — no existing data affected
- Index creation with
CONCURRENTLY— already non-locking
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.

