Why this matters
Improves readability and can reduce lock duration.
Group column/index changes with change_table; use concurrent indexes when needed.
Improves readability and can reduce lock duration.
Side-by-side examples engineers can pattern-match during review.
add_column :users, :locale, :string
add_index :users, :localechange_table :users do |t|
t.string :locale
end
add_index :users, :locale, algorithm: :concurrentlymultiple scattered DDL callschange_table + concurrent indexFrom the same buckets as this rule.
Review SQL/database migrations for operations that can lock large tables or cause downtime. Examples: creating indexes without CONCURRENTLY (Postgres), ALTER COLUMN TYPE on big tables, adding NOT NULL without backfill, long-running updates without batching. Require an online migration strategy (CONCURRENTLY, backfill in batches, dual-write/expand-contract) and a rollback plan.