database-migrations-sql-migrations

Generates zero-downtime SQL migration scripts with validation and rollback procedures for PostgreSQL, MySQL, and SQL Server.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-migrations-sql-migrations-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations-sql-migrations
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/database-migrations-sql-migrations
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill database-migrations-sql-migrations-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Changing production database schemas without downtime or data loss is risky and error-prone. This Skill produces structured migration plans, version-controlled SQL scripts, validation checks, and rollback procedures so schema changes can be deployed safely on live systems. ## Core Features & Use Cases - Zero-Downtime Strategies: Implements expand-contract and blue-green migration patterns with dual-write triggers and batched backfills. - Validation & Rollback: Provides pre/post-migration integrity checks, snapshot-based recovery, and automated rollback scripts. - Performance Optimization: Covers batch processing, parallel partition migration, and concurrent index rebuilds for large tables. - Use Case: When adding a NOT NULL column to a 50-million-row PostgreSQL table, use this Skill to generate a phased migration with a NOT VALID check constraint, batched backfill, and a tested rollback path. ## Quick Start Ask the AI to design a zero-downtime migration plan with rollback procedures for adding a new column to your PostgreSQL users table.

Frequently Asked Questions about database-migrations-sql-migrations

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

FAQPage Schema
How do I run a zero-downtime database migration in PostgreSQL?

Use the expand-contract pattern: first add new columns or tables in a backward-compatible way, then backfill data in batches, and finally drop old structures after code deployment. Create indexes with CREATE INDEX CONCURRENTLY to avoid table locks.

How to add a NOT NULL column to a large table without downtime?

Add the column as nullable, backfill values in batches, then add a CHECK constraint with NOT VALID and validate it separately. In PostgreSQL 12+, this avoids a full table rewrite and long exclusive locks.

What is the difference between Flyway and Alembic migrations?

Flyway uses versioned plain SQL files applied in order, while Alembic generates Python migration scripts with upgrade and downgrade functions from SQLAlchemy models. Both integrate with version control and support rollback paths.

How do I backfill millions of rows without locking the table?

Process rows in batches of around 10,000 using keyset pagination on an indexed cursor column, committing after each batch and adding short sleeps between iterations. For very large tables, partition the key range and migrate partitions in parallel with multiple workers.

How do I roll back a failed database migration safely?

Take a snapshot or backup before applying changes, run the migration inside a transaction with validation checks, and keep a tested down migration script for each version. If post-migration validation fails, restore from the snapshot and delete the version record from the schema_migrations table.

When should I not use an online schema change approach?

Avoid it when the change requires rewriting the entire table with incompatible data types, when dual-write synchronization cannot capture all write paths, or when the database version lacks concurrent index and constraint validation features. In those cases, schedule a maintenance window instead.