database-migrations

Design safe, reversible PostgreSQL database migrations with rollback planning.

1|Updated Mar 6, 2026
One-click install
npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill database-migrations-khetansarvesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/khetansarvesh/ai_skills_repo/tree/main/skills/database-migrations
Command: npx skills add https://github.com/khetansarvesh/ai_skills_repo --skill database-migrations-khetansarvesh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you reduce production risk when applying database schema and data changes by enforcing safe, reversible, and deployment-friendly migration practices.

Core Features & Use Cases

  • Production-safe migration patterns: Covers forward-and-rollback strategy, immutability of deployed migrations, and separation of schema vs. data operations.
  • Zero-downtime tactics: Implements expand–migrate–contract workflows, concurrent index strategies, and safe column add/remove/rename approaches.
  • Cross-platform guidance: Provides migration workflows and examples for PostgreSQL, MySQL patterns, and common ORMs/tooling (Prisma, Drizzle, Django, TypeORM-style approaches, golang-migrate).
  • Use case: When you need to add a new column or change indexing on a large table, you can follow these patterns to avoid table locks and ensure data backfills are handled in separate, testable steps.

Quick Start

Use this Skill to plan a zero-downtime migration (expand–migrate–contract) for a large PostgreSQL table change, including the UP/DOWN rollback approach and a separate batched data backfill strategy.

Frequently Asked Questions about database-migrations

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

FAQPage Schema
How do I run zero downtime database migrations on a large PostgreSQL table?

Zero downtime PostgreSQL migrations use the expand–migrate–contract workflow to separate schema changes from data backfills, applying concurrent index creation and batched updates to avoid table locks during production deployments.

What is the safest way to add a NOT NULL column without locking the database?

Adding a NOT NULL column safely requires a multi-step migration: first add the column with a default value, backfill the data in batches, then enforce the NOT NULL constraint to prevent table locks and application downtime.

Can I use this migration workflow with ORM tooling like Prisma or TypeORM?

Yes, the workflow provides cross-platform guidance for common ORM tooling including Prisma, Drizzle, Django, TypeORM, and golang-migrate to ensure safe schema change patterns and rollback strategies within your existing toolchain.

How do you create a rollback strategy for data backfills and schema changes?

A rollback strategy for data backfills requires immutable migration files with separate UP and DOWN paths, ensuring DDL and DML operations are isolated so schema changes and data transforms can be safely reversed if production validation fails.

Why should schema changes be separated from data backfill operations?

Separating schema changes from data backfill operations prevents long-running table locks during migrations, allowing DDL like concurrent index creation to execute independently of batched DML data transforms for safer production deployments.