Skip to content
Back to skills

Db Migration

ASecurity

Plans and writes schema changes and database migrations safely (compatibility, backfill, rollback, validation). Use whenever a change touches the schema or migrations, with "/db-migration", "add a column", "change table X" or similar.

  • 6 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added October 10, 2026
ai-agentsgosqldatabase

Security analysis

A100/100

Scanned November 10, 2026

npx -y skills add lautioliver/barrilete-kit --skill db-migration --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Db Migration?

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

Security grade badge for Db Migration
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lautioliver-db-migration/badge)](https://www.skillsdirectory.com/skills/lautioliver-db-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: db-migration
description: Plans and writes schema changes and database migrations safely (compatibility, backfill, rollback, validation). Use whenever a change touches the schema or migrations, with "/db-migration", "add a column", "change table X" or similar.
---

# Database migration

A schema change is among the hardest things to revert: data that is already migrated does not come back on its own. That is why it requires approval (AGENTS.md, "Agent autonomy" section) and this plan **before** writing the migration.

The concrete commands (generate a migration, run it locally, tests) are in `AGENTS.md`. TODO: if the project has a migration tool (Drizzle, Prisma, Alembic, hand-written SQL…), document its particulars here.

## 1. Plan (show it and wait for approval)

Touching the schema also requires the approval that the "Agent autonomy" section of `AGENTS.md` asks for: ask for both in the same message, with this table. Then the full table goes into the PR.

| Point | What to answer |
|---|---|
| Current schema | Tables/columns/indexes/constraints involved, as they are today (read it from the schema code, not from memory). |
| Desired schema | The exact change. |
| Compatibility | Does the code deployed today keep working with the new schema? (versions coexist during the deploy). Are there external readers (reports, other services)? |
| Migration | SQL steps. Does it lock the table? How long does it take with the production volume? |
| Backfill | Does existing data need to be filled in? How, in batches, idempotent? |
| Rollback | How to go back. If it cannot be done without losing data, say so explicitly. |
| Validation | How to check afterwards that it came out right (queries, counts, tests). |

## 2. Rules

- **Destructive changes in two steps** (expand / contract): first add the new thing and make the code use both; in a later PR, when nothing uses the old one, delete it. Never rename or drop a column in use in a single deploy.
- New `NOT NULL` column on a table with data: add it nullable or with a default → backfill → only then `NOT NULL`.
- Indexes on large tables: concurrently if the engine allows it.
- Invariants in the database (constraints, `CHECK`, `UNIQUE`) when the rule has to hold always; not only in the code.
- Migrations are immutable once merged: if something has to be fixed, a new migration.
- **Never** run migrations against shared environments or production. Only local or the test database.

## 3. Implement

1. Change the schema and generate the migration with the project's tool. Review the generated SQL line by line.
2. Run it locally / in tests from scratch and over existing data.
3. Tests: the new behavior, and that the old data is still valid.
4. Docs: `docs/reference/domain.md` (and whatever `agents_map.py` says). If it is a data-model decision that is hard to revert, an ADR.

## 4. PR

In the PR body, the full table from step 1, rollback included. If it is a two-step change, say which step it is in and open the issue for the next one (`create-issue`, blocked by this one).

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.

View all in ai-agents →

Comments

Loading comments…

Newsletter

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