safe-migration

Plans zero-downtime database schema migrations using the expand-migrate-contract pattern.

Updated Sep 10, 2026
One-click install
npx skills add https://github.com/serpro-workshop-fortaleza/datacorp-sifap-modernization-team-kit --skill safe-migration-serpro-workshop-fortaleza
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: safe-migration
Source: https://github.com/serpro-workshop-fortaleza/datacorp-sifap-modernization-team-kit/tree/main/.github/skills/safe-migration
Command: npx skills add https://github.com/serpro-workshop-fortaleza/datacorp-sifap-modernization-team-kit --skill safe-migration-serpro-workshop-fortaleza

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing a live database schema without downtime is risky: a single blocking ALTER TABLE, an irreversible rename, or a one-shot backfill can lock tables, break replicas, or force an outage. This Skill guides you through planning schema changes so every destructive modification is split into safe, reversible deployments. ## Core Features & Use Cases - Expand-Migrate-Contract Pattern: Structures every schema change into three deployments so destructive changes never happen in a single release. - Batched Backfills & Online Indexing: Enforces idempotent, batched backfills with LIMIT and pauses, plus CREATE INDEX CONCURRENTLY or ONLINE=ON index creation. - Pre-Deployment Checklist & Output Template: Produces a migration plan with forward and rollback plans, lock-impact estimates, and red-flag warnings before you deploy. - Use Case: You need to rename a heavily used column in production. The Skill walks you through adding a new column, dual-writing, backfilling in batches, switching reads behind a feature flag, and only then dropping the old column. ## Quick Start Ask the AI to plan a zero-downtime migration for renaming a column in your production PostgreSQL table using the expand-migrate-contract pattern.

Frequently Asked Questions about safe-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I rename a database column without downtime?▼

Never rename directly. Add a new column, dual-write to both columns, backfill historical rows in batches, switch reads to the new column behind a feature flag, and drop the old column only after the new one is authoritative for a full release cycle.

What is the expand and contract migration pattern?▼

Expand-migrate-contract splits every schema change into three deployments: expand adds the new structure alongside the old, migrate dual-writes and backfills then switches reads, and contract removes the old structure after the new one is authoritative.

How do I create an index on a large table without locking it?▼

Use CREATE INDEX CONCURRENTLY on PostgreSQL or ONLINE=ON on MySQL 8 and SQL Server so the table stays readable and writable. Monitor lock escalation during the build to catch blocking before it affects traffic.

How should I backfill millions of rows safely?▼

Run backfills in small batches with LIMIT, pauses between batches, and idempotent logic so reruns are safe. Size the batch according to your replica lag budget and never update the whole table in a single transaction.

Which schema changes are safe to deploy in a single release?▼

Additive changes are always safe: a new nullable column, a new table, or a new index created concurrently. Destructive changes like drops, renames, type changes, or adding NOT NULL must be split across multiple deployments.

When should I not deploy a database migration?▼

Do not deploy a single ALTER TABLE that fully locks a large table, a migration coupled to the app deploy that cannot roll back independently, an irreversible step without a backup, or a backfill rewriting all rows in one transaction.