Skip to content
Back to skills

Database Migrations

ASecurity

Zero-downtime schema migrations — expand/contract, backward compatibility with the running release, online index creation, batched backfills with throttling, constraint validation, lock timeouts, rollback notes, migration tooling. Use for any schema or data migration (migration, expand contract, backfill, zero downtime, schema change).

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgodatabase

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add vectora-os/kit --skill database-migrations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database Migrations?

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

Security grade badge for Database Migrations
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectora-os-database-migrations/badge)](https://www.skillsdirectory.com/skills/vectora-os-database-migrations)

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: database-migrations
description: Zero-downtime schema migrations — expand/contract, backward compatibility with the running release, online index creation, batched backfills with throttling, constraint validation, lock timeouts, rollback notes, migration tooling. Use for any schema or data migration (migration, expand contract, backfill, zero downtime, schema change).
metadata:
  category: data
---

# Database migrations

## Purpose

Change schemas without downtime and with a way back.

**Use when:** every schema or data migration.

**Not for:** logical model design.

## Inputs

- Current and target schema, table sizes, release plan.

## Outputs

- Migration scripts, backfill plan, rollback notes, checklist.

## Read first

- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "database migrations"` for prior decisions, patterns and anti-patterns.
- [Migration review checklist](../../../checklists/migration-review.md)

## Steps

1. **Expand.** Additive changes compatible with the current code.
   Done when old code works with new schema.
2. **Backfill.** Batched, throttled, idempotent, resumable.
   Done when backfill measured on a copy.
3. **Switch.** Code reads/writes new structure behind a flag.
   Done when flag can revert.
4. **Contract.** Remove old structures in a later release.
   Done when no code references them.

## Best practices

- Set `lock_timeout` and `statement_timeout` in migrations.
- Never rename in place.

## Common mistakes

- Adding NOT NULL with default on huge tables in old engines.
- Migration and code change that only work together.

## Example

Rename `email` → `email_address`: add column, dual-write, backfill, switch reads, drop old column next release.

## Reusable prompt

```text
Apply the Database migrations skill (.agents/skills/database-migrations/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Plan the migration as expand, backfill, switch, contract with timings, lock safety and rollback per step.
Return: Migration scripts, backfill plan, rollback notes, checklist..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```

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.