DevOps, CI/CD & Infrastructure
Compatible with Cursor, Claude Code, Cline, Roo Code, Antigravity

Database Zero-Downtime Migration & Rollback Orchestration

Plan high-volume, live table restructuring and large column migrations without application outages.

DatabasePostgreSQLDevOpsMigrationsZero-Downtime
Skill Objective

Orchestrate multi-phase Expand/Contract migrations for multi-million row tables: additive schema changes, throttled dual-writing backfills, read cutovers, and safe contraction.

Execution Workflow Procedure

Ordered steps the coding agent executes when performing this skill.

1

Phase 1: Expand (Additive Schema Change)

Execute DDL adding new columns with lock_timeout guards, ensuring running application pods remain unaffected.

2

Phase 2: Dual-Writing & Throttled Backfill

Update application code to write to both columns and run a batched background script to backfill historical rows.

3

Phase 3: Switch Reads & Verify

Switch application reads to the new schema and monitor latency and error rates.

4

Phase 4: Contract (Cleanup)

Safely drop the deprecated column in a follow-up release after verification.

Agent Safety Guardrails & Anti-Hallucination Rules

  • DO NOT execute un-throttled UPDATE statements across millions of rows that trigger replication lag.
  • DO NOT drop old columns before full verification across at least one production release cycle.

Expected Output Format

Phased rollout steps with backfill scripts and rollback plans.

📋 4-Phase Migration Plan: Expand, Dual-Write, Read Switch, Contract.
🛠️ Backfill Script & DDL: SQL/Python batch migration scripts.

Domain Verification Checks

Expand/Contract Phasing: Separates schema rollout across multiple application deployments.
Lock Timeout Guard: Sets SET lock_timeout = '50ms' before executing DDL.
Throttled Backfills: Iterates backfills in batches of 1,000 rows with sleep intervals.

Example Agent Invocations

"Design a zero-downtime migration to change primary keys from SERIAL to UUIDv7 on a 40M row table."
"Plan the non-breaking migration of user password hashes to multi-factor credential JSONB columns."

Install / Configure This Skill

# Place in .cursorrules or create .cursor/rules/zero-downtime-database-migration-strategy.mdc
# Trigger: Whenever you perform database zero-downtime migration & rollback orchestration

---
name: zero-downtime-database-migration-strategy
description: Orchestrate multi-phase zero-downtime database migrations with Expand/Contract patterns and throttled backfills.
version: 1.0.0
compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity]
---

# Database Zero-Downtime Migration & Rollback Orchestration

## Objective
Restructure high-traffic database tables and execute large backfills without downtime or replication lag.

## Workflow
1. **Expand Phase**: Add additive columns with strict `lock_timeout` settings.
2. **Dual-Writing & Backfill**: Write to both columns while backfilling historical data in throttled batches.
3. **Read Switch**: Shift application queries to the new structure.
4. **Contract Phase**: Clean up old columns in a subsequent release cycle.
Complementary Agent Prompt

Need a quick one-time prompt for chat?

Try the Database Zero-Downtime Migration & Rollback Strategy — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.

View Prompt

SprintKit Workflow Integrations

Complementary tools and checklists to pair with this agent workflow.

Related Agent Skills

Explore related procedural workflows in this discipline.

All Skills

Database Migration Rollback & Data Integrity Validation

Validate database schema migrations for zero data loss, backward compatibility, and forward/backward rollbacks.

SQLDatabaseMigrations+3
3 workflow stepsView skill

Relational Database Schema Normalization & Indexing Strategy

Design production PostgreSQL schemas with composite indexes, foreign key strategies, and partitioning.

PostgreSQLSQLDatabase+2
3 workflow stepsView skill

Database Deadlock & Concurrency Race Condition Diagnosis

Diagnose Postgres/MySQL transaction deadlocks, lock contention, and concurrent update race conditions.

SQLPostgreSQLMySQL+3
3 workflow stepsView skill