Safe migration workflow with production checks
Execute database migrations with safety checks that detect dangerous operations like table locks, data loss risks, and irreversible changes before running them.
/plugin marketplace add betamatt/claude-plugins/plugin install ruby-on-rails@betamatt-claude-pluginsup|down|redo|status|rollbackExecute database migrations with safety checks and production awareness.
/rails:migrate [action]
status - Show migration statusrollback - Rollback last migrationredo - Rollback and re-run last migrationup VERSION=xxx - Run specific migration updown VERSION=xxx - Run specific migration downBefore running migrations, verify:
Pending migrations exist
bin/rails db:migrate:status
Review migration content
remove_column without ignored_columnschange_column on large tablesadd_column with null: false without defaultCheck for irreversible migrations
change_column without explicit up/downFlag these patterns with warnings:
# WARNING: May lock table
add_index :large_table, :column # Should use algorithm: :concurrently
change_column :table, :column, :new_type # May rewrite table
# WARNING: Irreversible
remove_column :orders, :status # Check ignored_columns first
drop_table :old_table # Ensure data is backed up
# WARNING: May take long time
add_column :users, :field, default: "value" # On large tables
# Rails 7+ handles this efficiently, but warn for older Rails
Before rollback:
Migration Status:
up 20231201120000 Create users
up 20231202130000 Add email to users
down 20231203140000 Add orders table (pending)
Pending Migrations:
20231203140000_add_orders_table.rb
- Creates orders table
- Adds foreign key to users
- Adds index on user_id
Safety Check: ✓ No concerns found
Running migrations...
== 20231203140000 AddOrdersTable: migrating ===
-- create_table(:orders)
-- add_index(:orders, :user_id)
== 20231203140000 AddOrdersTable: migrated (0.0123s) ===
✓ Migration complete
/migrateCode migration between frameworks and technologies with systematic planning and validation.