Skip to content
Back to skills

Migration

ASecurity

Write a forward/backward database migration that applies and rolls back cleanly

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 3, 2026
ai-agentsgosqlrailsdatabase

Security analysis

A100/100

Scanned September 3, 2026

npx -y skills add black141312/ada --skill migration --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Migration?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Migration
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/black141312-migration/badge)](https://www.skillsdirectory.com/skills/black141312-migration)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: migration
description: Write a forward/backward database migration that applies and rolls back cleanly
category: database
---

# Migration

Reach for this when you need to change a database schema (add/alter/drop columns, tables, indexes, constraints) in a way that is versioned, reviewable, and reversible.

1. Inspect the current schema and existing migrations to match naming, ordering, and the tool in use (e.g. Alembic, Prisma, Knex, Rails, raw SQL).
2. Write the `up` step: the smallest set of DDL/DML that achieves the change; split risky data backfills into their own step.
3. Write the `down` step that exactly reverses `up` (drop what you created, restore what you altered); never leave it as a no-op if `up` is reversible.
4. For non-trivial column changes, use the expand/contract pattern: add new, backfill, switch reads/writes, then drop old in a later migration.
5. Apply the migration on a scratch/dev database, then roll it back, then re-apply to prove both directions work.
6. Wrap each migration in a transaction where the engine allows it; flag operations that can't run transactionally (e.g. Postgres `CREATE INDEX CONCURRENTLY`).

## Rules
- One logical change per migration; never edit a migration that has already shipped — add a new one.
- Make column adds nullable or defaulted so they don't lock/fail on populated tables.
- Backfill large tables in batches, not a single `UPDATE`, to avoid long locks.
- Test `down` for real; an irreversible migration must say so explicitly and explain the recovery path.
- Keep migrations free of app code/ORM model imports so they still run after the models change.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.