Skip to content
Back to skills

Schema Migration Safety

ASecurity

Use when writing database schema migrations or changing tables, columns, indexes, or constraints on a system with real data

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 6, 2026
ai-agentssqldatabase

Security analysis

A100/100

Scanned September 6, 2026

npx -y skills add yuchi-chang/no-cape --skill schema-migration-safety --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Schema Migration Safety?

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

Security grade badge for Schema Migration Safety
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yuchi-chang-schema-migration-safety/badge)](https://www.skillsdirectory.com/skills/yuchi-chang-schema-migration-safety)

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: schema-migration-safety
description: Use when writing database schema migrations or changing tables, columns, indexes, or constraints on a system with real data
---

# Schema Migration Safety

Live data and running code make schema changes a deployment problem, not just a SQL problem: during every deploy, the *old* code version runs against the *new* schema.

## Expand–contract

Never break in one step. Split every breaking change:

1. **Expand:** add the new column/table/index alongside the old. Deploy code that writes both, reads old.
2. **Migrate:** backfill data; switch reads to the new path.
3. **Contract:** only after the old path is provably unused, remove it — in a later release.

A rename is a drop-and-add in disguise: same treatment.

## Rules

- Every migration has a tested rollback, or is explicitly documented as irreversible and confirmed with the user.
- No large data transformation inside a schema migration — backfill in batches as a separate job. A migration that locks a big table is an outage.
- Adding NOT NULL or constraints to existing columns: check existing data first, or add with a default / as NOT VALID, then validate separately.
- Index creation on large tables: use the non-blocking variant (e.g. `CREATE INDEX CONCURRENTLY` in Postgres).
- Destructive operations (DROP, mass DELETE/UPDATE): state the affected row counts, confirm a verified backup exists, and get explicit confirmation before running.

## Smell test

"Old app version + new schema: does every query still work?" If no, another expand step is missing.

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…