Why this matters
Prevents memory bloat and long locks.
Process large tables with find_in_batches and avoid loading entire datasets.
Prevents memory bloat and long locks.
Side-by-side examples engineers can pattern-match during review.
User.all.each { |u| backfill(u) }User.find_in_batches(batch_size: 1000) { |batch| batch.each { backfill(_1) } }Model.all.eachModel.find_in_batchesFrom 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.