database-migrations

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

Updated Jun 13, 2026
One-click install
npx skills add https://github.com/malinovskiy-makar/qls --skill database-migrations-malinovskiy-makar
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/malinovskiy-makar/qls/tree/main/.claude/skills/database-migrations
Command: npx skills add https://github.com/malinovskiy-makar/qls --skill database-migrations-malinovskiy-makar

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Schema changes on production databases risk table locks, downtime, and irreversible data loss when migrations are written carelessly. This Skill provides proven patterns for writing safe, reversible migrations and planning zero-downtime deployments. ## Core Features & Use Cases - Migration Safety Checklist: Enforces rules like nullable new columns, concurrent index creation, and separating schema from data migrations. - Multi-Tool Coverage: Includes concrete workflows and code examples for PostgreSQL, Prisma, Drizzle, Kysely, Django, and golang-migrate. - Zero-Downtime Patterns: Guides the expand-contract pattern for renaming or removing columns without breaking running applications. - Use Case: You need to rename a username column on a 10M-row users table. Follow the expand-contract steps: add the new column, backfill in batches, deploy dual-writing code, then drop the old column in a later migration. ## Quick Start Ask the AI to write a safe migration that adds a non-null column with an index to a large 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. Never add NOT NULL without a default on an existing table, since that locks the table and rewrites every row.

How do I rename a database column in production safely?

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

Prisma vs Drizzle vs Kysely for database migrations?

Prisma generates migrations from schema files 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.

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 creates long transactions, makes rollbacks harder, and increases lock duration on production tables.

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

Update rows in batches rather than one large transaction. In PostgreSQL, loop over batches with LIMIT and FOR UPDATE SKIP LOCKED, committing between batches; in Django, use bulk_update with a batch size inside a RunPython data migration.