safe-migrations

Write production-safe Ruby on Rails migrations with strong_migrations rules and Postgres syntax.

21|2|Updated May 24, 2026
One-click install
npx skills add https://github.com/sandeepmvl/rails-skills --skill safe-migrations-sandeepmvl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: safe-migrations
Source: https://github.com/sandeepmvl/rails-skills/tree/main/skills/05-safe-migrations
Command: npx skills add https://github.com/sandeepmvl/rails-skills --skill safe-migrations-sandeepmvl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Default AI-generated Rails migrations often cause full table locks, production downtime, and 502 errors on large tables, as they ignore production-safe patterns and strong_migrations gem guardrails.

Core Features & Use Cases

  • Strong Migrations Enforcement: Teaches AI agents to follow strong_migrations rules to catch dangerous migration patterns before they run in production.
  • Multi-Deploy Split Patterns: Provides backwards-compatible step-by-step sequences for high-risk schema changes including adding/removing columns, renaming columns, and changing column types.
  • Postgres-Specific Safe Syntax: Covers concurrent index creation, non-blocking foreign key validation, and check constraint workflows for large PostgreSQL tables.
  • Batched Backfill Guidance: Includes throttled, resumable backfill templates that avoid replica lag and memory overflows on large datasets. Use this skill when adding a column to a 50M-row users table, adding an index to a 100M-row orders table, or removing a legacy column without crashing running app servers.

Quick Start

Use the safe-migrations skill to write a zero-downtime migration to add a non-null role column with a default "member" value to your 50M-row users table without locking the table or causing downtime.

Frequently Asked Questions about safe-migrations

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

FAQPage Schema
How do I add a column to a large Postgres table without locking it in Rails?

To add a column to a large Postgres table without locking it in Rails, use multi-deploy split patterns that separate schema changes from data backfills. This ensures backwards compatibility and prevents downtime on large production tables.

What is the safe way to backfill existing data on a 50M-row table in Rails?

The safe way to backfill existing data on a 50M-row table in Rails is using batched backfill templates with throttling. This method prevents replica lag and memory overflows by processing data in resumable batches.

Why does adding an index cause downtime on large database schema changes?

Adding an index causes downtime on large database schema changes because standard operations acquire an exclusive table lock. Using Postgres-specific concurrent index creation syntax avoids this lock, enabling zero-downtime migrations.

Does strong_migrations work with Postgres check constraint workflows?

Yes, strong_migrations works with Postgres check constraint workflows by enforcing non-blocking constraint validation. It guides safe syntax for adding and validating check constraints without causing production downtime.

When do I need multi-deploy split patterns for Rails database schema changes?

You need multi-deploy split patterns for Rails database schema changes when performing high-risk operations like renaming columns, removing columns, or changing column types. These patterns ensure backwards compatibility to prevent app server crashes.