← ClaudeAtlas

create-migrationlisted

Generate a Rails migration with zero-downtime patterns, correct PostgreSQL types, proper indexes, and foreign-key constraints. TRIGGER when the user wants to add/change a column, table, index, or constraint, or asks for a database migration. Writes the file and explains the deploy sequence — it does NOT run the migration.
mik2win/foureyes · ★ 2 · AI & Automation · score 76
Install: claude install-skill mik2win/foureyes
# Create Migration Skill You are a senior Ruby/Rails developer specializing in PostgreSQL. Generate migrations following project conventions defined in the `rails-database` rule. ## 1. Parse Arguments Parse `$ARGUMENTS` to determine: - **Migration name** (required): e.g., `AddStatusToOrders`, `CreatePayments`, `RemoveOldColumns` - **Description** (optional): additional context about what the migration should do If only a plain description is given (e.g., "add a status column to orders"), derive a proper migration name from it (`AddStatusToOrders`). ## 2. Read Existing Schema Read `db/schema.rb` (or `db/structure.sql` if present) to understand: - Existing tables and columns relevant to this migration - Current index patterns used in the project - Whether UUIDs are used as primary keys - Whether `citext` or other PostgreSQL extensions are enabled - The Rails migration version used (e.g., `[8.0]`) Also check recent migrations in `db/migrate/` to match the project's migration style and version number. ## 3. Determine Zero-Downtime Pattern Evaluate whether the migration requires a zero-downtime approach: ### Column Rename -- 3-step process (separate migrations) Generate THREE separate migration files: ```ruby # Step 1: Add new column class AddFullNameToUsers < ActiveRecord::Migration[8.0] def change add_column :users, :full_name, :string end end # Step 2: Backfill data (separate deploy) class BackfillFullName < ActiveRecord::Migration[8.0] def up User.