database-migrations

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

5|Updated Jul 8, 2019
One-click install
npx skills add https://github.com/rinchsan/dotfiles --skill database-migrations-rinchsan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/rinchsan/dotfiles/tree/main/.claude/skills/database-migrations
Command: npx skills add https://github.com/rinchsan/dotfiles --skill database-migrations-rinchsan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Changing production database schemas without downtime or data loss is risky: a single bad migration can lock tables, rewrite millions of rows, or break running applications. This Skill provides proven patterns for writing safe, reversible migrations and planning zero-downtime schema changes. ## Core Features & Use Cases - Safety Checklists: Enforces rules like never adding NOT NULL without a default, using CREATE INDEX CONCURRENTLY, and separating schema from data migrations. - Multi-Tool Coverage: Includes concrete workflows and code examples for Prisma, Drizzle, Django, golang-migrate, and raw PostgreSQL. - Zero-Downtime Patterns: Guides the expand-contract pattern for renaming or removing columns without breaking deployed applications. - Use Case: You need to rename a heavily used column in a production PostgreSQL table. The Skill walks you through adding the new column, backfilling data in batches, deploying dual-write application code, and dropping the old column in a later migration. ## Quick Start Ask the assistant to help you write a safe migration to add a non-nullable column with an index to your production users table.

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. Never add NOT NULL without a default on an existing table, since that locks the table and rewrites every row.

How to rename a database column in production safely?

Use the expand-contract pattern instead of a direct rename. Add the new column, backfill existing data, deploy application code that writes to both columns, then drop the old column in a separate later migration.

Prisma vs Django migrations for schema changes?

Prisma uses prisma migrate dev to generate SQL from schema changes and supports custom SQL via --create-only for operations like concurrent indexes. Django uses makemigrations and migrate, with SeparateDatabaseAndState for removing model fields without immediately dropping columns.

Why does CREATE INDEX lock my PostgreSQL table?

A plain CREATE INDEX blocks writes on large tables while the index builds. Use CREATE INDEX CONCURRENTLY instead, which allows concurrent writes, though it cannot run inside a transaction block and may need special handling in migration tools.

Should schema and data migrations be in the same migration file?

No, schema and data migrations should be separate. Mixing DDL and DML in one migration makes rollbacks harder and creates long-running transactions; run the schema change first, then backfill data in a separate batched migration.