database-migrations

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

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

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 - Migration Safety Checklist: Enforces rules like concurrent index creation, nullable-first column additions, and separation of schema and data migrations. - Multi-Tool Coverage: Includes concrete workflows and code for Prisma, Drizzle, Kysely, Django, and golang-migrate, plus raw PostgreSQL patterns. - Zero-Downtime Strategy: Guides the expand-contract pattern for renaming or removing columns without downtime, including batched backfills. - 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, deploying dual-write code, and dropping the old column in a later migration. ## Quick Start Ask the assistant to plan a zero-downtime migration that adds a non-null column with an index to a large PostgreSQL table using your 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 adding 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 instead of a direct rename. Add the new column, backfill data in a separate migration, deploy code that writes to both columns, then drop the old column in a later migration after reads switch over.

Why does CREATE INDEX lock my table during migration?

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

Can Prisma generate concurrent indexes or custom SQL migrations?

Prisma cannot generate CONCURRENTLY indexes automatically. Run prisma migrate dev --create-only to produce an empty migration file, then write the raw SQL such as CREATE INDEX CONCURRENTLY manually before applying it.

Should schema changes and data backfills be in the same migration?

No, schema and data migrations should be separate. Mixing DDL and DML in one migration creates long transactions that are hard to roll back; backfill large tables in batches as a follow-up migration instead.

What should I do instead of editing a migration already deployed to production?

Never edit a migration that has run in production, since it causes drift between environments. Create a new forward migration that corrects the schema, and document the rollback plan for the change.