database-migration-patterns

Apply Expand and Contract patterns for zero-downtime database migrations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/neverprepared/ink-bunny --skill database-migration-patterns-neverprepared
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migration-patterns
Source: https://github.com/neverprepared/ink-bunny/tree/main/reflex/plugins/reflex/skills/database-migration-patterns
Command: npx skills add https://github.com/neverprepared/ink-bunny --skill database-migration-patterns-neverprepared

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Database migrations are risky and can cause downtime, data loss, and deployment delays. This Skill provides structured patterns and best practices to perform schema changes and data migrations safely.

Core Features & Use Cases

  • Expand and Contract pattern for non-breaking schema changes with backfilling and switch.
  • Safe Column Rename approach to minimize downtime.
  • Safe Index Creation techniques to avoid long locks.
  • NOT NULL transition patterns with phased rollout and validation.
  • Batch processing and data migration workflows for large tables.
  • Version-controlled migrations with auditable templates and rollback guidance.

Quick Start

Apply the Expand and Contract pattern to add a new column, backfill data in batches, then swap to the new column and remove the old one.

Frequently Asked Questions about database-migration-patterns

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

FAQPage Schema
How do I perform zero-downtime database migrations in PostgreSQL?

Zero-downtime database migrations in PostgreSQL use the Expand and Contract pattern to add new schema elements, backfill data in batches, then swap traffic and remove the old structure. This avoids long table locks and service disruption.

What is the Expand and Contract pattern for database schema changes?

The Expand and Contract pattern expands the schema by adding new columns, contracts it by backfilling data and switching application traffic, then removes the obsolete columns. It enables safe schema evolution without breaking compatibility.

How do I safely add a NOT NULL constraint to an existing column?

Safe NOT NULL transitions require a phased rollout: add a default value, backfill existing rows, validate constraints, and finally enforce NOT NULL. This prevents lock contention and write failures during production deployment.

What is the best way to rename a database column without downtime?

A safe column rename uses Expand and Contract by adding the new column, dual-writing to both columns, backfilling historical data, switching reads to the new column, and finally dropping the old column. This ensures continuous availability.

How do I create large indexes without locking production tables?

Safe index creation avoids long locks by using concurrent indexing techniques. By building indexes in the background, the database allows continued reads and writes, preventing deployment delays and downtime on large tables.

Can I use these migration patterns with Alembic for batch data backfills?

Yes, the patterns support batch processing and data migration workflows for large tables. Using version-controlled migrations with auditable templates, you can execute batch backfills and rollback operations safely within your migration framework.