rails-migrations

Generate reversible, non-blocking Rails migrations with two-phase column removals.

2|Updated May 15, 2015
One-click install
npx skills add https://github.com/stephendolan/dotfiles --skill rails-migrations
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rails-migrations
Source: https://github.com/stephendolan/dotfiles/tree/main/claude/skills/rails-migrations
Command: npx skills add https://github.com/stephendolan/dotfiles --skill rails-migrations

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill teaches safe migration strategies to minimize downtime and ensure reversibility during schema changes.

Core Features & Use Cases

  • Two-Phase Column Removal: Remove deprecated columns in two phases to avoid runtime errors.
  • Strong Migrations: Apply non-blocking changes and proper backfills.
  • Pre-Deployment Cleanup: Guidance for data cleanup before risky changes.

Quick Start

Add a NOT NULL constraint safely using a two-phase approach with a pre-deployment backfill.

Frequently Asked Questions about rails-migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely remove a column from a Rails database without causing downtime?

Two-phase column removal eliminates runtime errors by deprecating the column first, then removing it in a separate deployment. This ensures older code finishes before the column disappears, maintaining backward compatibility across deployments.

What are zero-downtime Rails migrations and why do I need them?

Zero-downtime migrations are schema changes deployed without stopping the application. They prevent errors when old and new code versions run simultaneously, using techniques like concurrent index creation and staged backfills to keep the database accessible during deployment.

How do I add a NOT NULL constraint to an existing Rails column safely?

Use a two-phase approach: backfill existing rows with a default value before deployment, then add the constraint in a separate migration. This prevents locking tables and ensures all data satisfies the constraint before enforcement.

What's the best way to handle large data backfills during Rails migrations?

Pre-deployment cleanup scripts process data in batches outside the migration, avoiding long-running transactions that lock tables. This technique completes backfills before deployment, making the actual migration fast and non-blocking.

Can I reverse a Rails migration if something goes wrong in production?

Reversible migrations include both `up` and `down` steps, enabling safe rollback if issues arise. Two-phase patterns and strong migrations ensure rollbacks don't corrupt data or break running application code.