DB
db-migration
Safely generates, reviews, and applies Alembic database migrations.
Install
mkdir -p .claude/skills/db-migration && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/16470" && unzip -o skill.zip -d .claude/skills/db-migration && rm skill.zipInstalls to .claude/skills/db-migration
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Safely generates, reviews, and applies Alembic database migrations.67 chars · catalog descriptionno explicit “when” trigger
About this skill
Skill: db-migration
Safely generates, reviews, and applies Alembic database migrations.
When to Use
- Adding new tables or columns
- Renaming columns (with a deprecation plan)
- Adding indexes or constraints
- Removing deprecated columns (after safe deprecation window)
Steps
-
Understand the schema change
- What model changed in
app/models/? - Is this additive (safe) or destructive (risky)?
- What model changed in
-
Generate the migration
alembic revision --autogenerate -m "description_of_change" -
Review the generated file (never skip this)
- Check
upgrade()matches what you intend - Check
downgrade()is correct and reversible - Watch for: dropped columns, renamed columns, changed types
- Autogenerate misses: partial indexes, custom constraints, enum changes
- Check
-
Test the migration
alembic upgrade head # apply alembic downgrade -1 # verify rollback works alembic upgrade head # re-apply -
Run tests after applying migration:
pytest -x -v
Safety Rules
- Never apply a migration that lacks a working
downgrade() - Never drop a column that is still referenced in code
- Rename columns in two releases: add new → migrate data → remove old
- Large table migrations (>1M rows) need
--lock-timeoutand offline strategy
Output
Report: migration filename, what it does, whether downgrade was tested, any risks.