database-migration-safety

Reviews database migrations for lock safety, rollback plans, and zero-downtime deployment patterns.

1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/dominionism/Noesis --skill database-migration-safety-dominionism
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: database-migration-safety
Source: https://github.com/dominionism/Noesis/tree/main/assets/skills/database-migration-safety
Command: npx skills add https://github.com/dominionism/Noesis --skill database-migration-safety-dominionism

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database migrations that lock tables, lose data, or break live traffic cause production outages. This Skill provides concrete patterns for writing migrations that are safe to run against large production tables during peak traffic. ## Core Features & Use Cases - Lock Classification: Reference tables showing which PostgreSQL and MySQL DDL operations block reads or writes and for how long. - Expand-Contract Pattern: Three-phase deployment strategy for column type changes, renames, and other breaking schema changes. - Safe Constraint and Index Patterns: NOT VALID + VALIDATE constraint workflows and CREATE INDEX CONCURRENTLY guidance, including ORM-specific gotchas for Prisma, Drizzle, Alembic, and Knex. - Use Case: Before merging a pull request that adds an index to a 50-million-row orders table, use this Skill to verify the migration uses CONCURRENTLY, has a rollback plan, and was tested against production-sized data. ## Quick Start Review this migration for production safety and tell me whether it will lock the users table under live traffic.

Frequently Asked Questions about database-migration-safety

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 with no default, which is a metadata-only operation in PostgreSQL. For defaults on PostgreSQL 11+, ADD COLUMN DEFAULT is also instant. On older versions, use the expand-contract pattern with a backfill in batches.

How to create an index on a production table without blocking writes?▼

Use CREATE INDEX CONCURRENTLY in PostgreSQL, which builds the index without blocking reads or writes. It cannot run inside a transaction, so disable transaction wrapping in your migration tool for that statement.

What is the expand-contract pattern for database migrations?▼

Expand-contract splits a breaking schema change into three deployments: add the new structure alongside the old, backfill data and switch reads, then remove the old structure. Each phase is a separate migration and deployment.

Does Prisma support CREATE INDEX CONCURRENTLY?▼

Prisma wraps migrations in transactions by default, which prevents CREATE INDEX CONCURRENTLY from running. Use a raw SQL migration or the appropriate escape hatch to execute concurrent index creation outside a transaction.

Why does adding a NOT NULL constraint lock my table?▼

ALTER COLUMN SET NOT NULL scans the entire table to validate existing rows, holding an AccessExclusiveLock during the scan. Instead, add a CHECK constraint as NOT VALID, validate it separately, then set NOT NULL, which is instant in PostgreSQL 12+.

When should I not run a migration during peak traffic?▼

Avoid operations that rewrite or fully scan large tables, such as ALTER COLUMN TYPE, ADD CONSTRAINT without NOT VALID, or plain CREATE INDEX. If lock duration exceeds 5 seconds in staging tests with production-sized data, use expand-contract or schedule off-peak.