database-migrations

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

Updated Mar 18, 2026
One-click install
npx skills add https://github.com/freedom909/real-estate-saas --skill database-migrations-freedom909
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/freedom909/real-estate-saas/tree/main/.trae/skills/database-migrations
Command: npx skills add https://github.com/freedom909/real-estate-saas --skill database-migrations-freedom909

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database schema changes in production are risky: a poorly written migration can lock tables, cause downtime, or corrupt data. This Skill provides proven patterns for writing safe, reversible migrations and planning zero-downtime schema changes. ## Core Features & Use Cases - Migration Safety Checklist: Enforces rules like concurrent index creation, nullable columns with defaults, and separation of schema and data migrations. - Multi-Tool Workflows: Covers Prisma, Drizzle, Kysely, Django, TypeORM, and golang-migrate with concrete commands and migration file examples. - Zero-Downtime Strategies: Guides the expand-contract pattern for renaming or removing columns without breaking running applications. - Use Case: When renaming a column on a 10M-row PostgreSQL table, follow the expand-contract pattern: add the new column, backfill in batches, deploy code reading the new column, then drop the old one in a later migration. ## Quick Start Ask the AI to help you write a safe migration for adding a NOT NULL column to a large PostgreSQL table using Prisma.

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 create an index on a large table without blocking writes?▼

Use CREATE INDEX CONCURRENTLY in PostgreSQL, which builds the index without blocking concurrent writes. Note that CONCURRENTLY cannot run inside a transaction block, so most migration tools need special handling for it.

Prisma vs Drizzle vs Kysely for database migrations?▼

Prisma generates migrations from schema diffs with prisma migrate dev, Drizzle uses drizzle-kit generate, and Kysely uses explicit up/down migration files via kysely-ctl. All three support custom SQL for operations like concurrent indexes.

How do I rename a column in production without breaking the app?▼

Use the expand-contract pattern: add the new column, backfill existing data, deploy code that writes to both columns, switch reads to the new column, then drop the old column in a separate migration. Never rename directly in production.

Why does my data migration lock the entire table?▼

Updating all rows in one transaction holds locks for the duration of the update. Batch the updates into chunks of a few thousand rows using FOR UPDATE SKIP LOCKED, committing between batches to release locks.

Can I edit a migration file after it has run in production?▼

No, deployed migrations are immutable. Editing them causes schema drift between environments because other databases already applied the original version. Always create a new forward migration to correct issues.