database-migrations

Implements safe, reversible database schema and data migrations across PostgreSQL and common ORMs.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill database-migrations-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/database-migrations
Command: npx skills add https://github.com/ibytechaos/claude --skill database-migrations-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing production database schemas without breaking running applications is risky: naive migrations lock tables, rewrite millions of rows, or leave no rollback path. This Skill provides proven patterns for safe, reversible schema changes and data migrations. ## Core Features & Use Cases - Safety Checklists & Anti-Patterns: Enforces rules like never adding NOT NULL without a default, using CREATE INDEX CONCURRENTLY, and separating schema from data migrations. - Multi-Tool Workflows: Covers Prisma, Drizzle, Kysely, Django, golang-migrate, and raw PostgreSQL with concrete commands and migration file examples. - Zero-Downtime Strategy: Guides the expand-contract pattern for renaming or removing columns across multiple deploys. - Use Case: You need to rename a username column on a 10M-row users table. The Skill walks you through adding a new column, backfilling in batches, dual-writing from the app, and dropping the old column in a later migration. ## Quick Start Ask the assistant to plan a zero-downtime migration that adds an indexed column to your PostgreSQL users table using your project's ORM.

Frequently Asked Questions about database-migrations

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

FAQPage Schema
How do I add a column to a large PostgreSQL table without downtime?

Add the column as nullable or with a default value, which PostgreSQL 11+ applies instantly without rewriting the table. Avoid NOT NULL without a default on existing tables, since that forces a full table rewrite and lock.

How to rename a database column in production safely?

Use the expand-contract pattern: add the new column, backfill existing rows, deploy code that writes to both columns, then drop the old column in a later migration. Never rename directly on a live production table.

Prisma vs Drizzle vs Kysely for database migrations?

Prisma uses migrate dev and migrate deploy with a declarative schema. Drizzle generates migrations via drizzle-kit generate. Kysely uses kysely-ctl with explicit up and down TypeScript migration files, giving the most manual control.

Why does CREATE INDEX lock my PostgreSQL table?

A plain CREATE INDEX blocks writes while the index builds on large tables. Use CREATE INDEX CONCURRENTLY instead, which allows concurrent writes, but note it cannot run inside a transaction block.

Can I edit a migration file after it ran in production?

No. Deployed migrations are immutable; editing them causes schema drift between environments. Always create a new forward migration to correct or extend a change that already ran.

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

Run the backfill as a separate data migration using batched updates, for example loops of 5000-10000 rows with FOR UPDATE SKIP LOCKED in PostgreSQL or Django bulk_update in chunks. Avoid single-transaction updates across the whole table.