database-migrations

Create safe, reversible Rails database migrations with strong_migrations validation.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/mlbright/notes --skill database-migrations-mlbright
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migrations
Source: https://github.com/mlbright/notes/tree/main/.github/skills/database-migrations
Command: npx skills add https://github.com/mlbright/notes --skill database-migrations-mlbright

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the critical need for safe, zero-downtime database migrations in production environments, preventing data loss and application instability.

Core Features & Use Cases

  • Safe Schema Changes: Provides patterns for adding/removing columns, indexes, and foreign keys without locking tables.
  • Zero-Downtime Deployments: Employs strategies like concurrent index creation and two-step NOT NULL constraints.
  • Reversible Migrations: Ensures migrations can be rolled back safely.
  • Use Case: When deploying a new feature that requires adding a new column to a high-traffic users table, use this Skill's patterns to add the column, backfill data, and then set the NOT NULL constraint in separate, safe steps.

Quick Start

Generate a new migration file for adding a status column to the events 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 NOT NULL column to a large PostgreSQL table without downtime in Rails?

To prevent locking large PostgreSQL tables, add the column, backfill existing rows, and enforce the NOT NULL constraint in separate migration steps to ensure zero-downtime deployments.

What is the best way to create indexes on large tables without blocking writes?

Concurrent index creation allows building indexes in the background without locking the table, ensuring the application maintains read and write access during the migration on large production tables.

How do I ensure my Rails database migrations are reversible?

Ensure Rails migrations are reversible by defining matching rollback methods that safely remove added columns, indexes, or foreign keys, allowing the database schema to return to its previous state without data loss.

Does strong_migrations work with SQLite and PostgreSQL for schema validation?

Yes, strong_migrations validates schema changes for PostgreSQL and SQLite, automatically detecting unsafe operations like blocking index creation to prevent table locks and application instability in production environments.

When do I need to split schema changes into multiple migration steps?

Split schema changes into multiple migration steps when operating on large production tables to avoid long table locks, specifically when adding columns with defaults, creating indexes, or adding foreign keys.