rea-analysis-optimization
MOmorluto/rea486k8,943 new stars in the last 7 days
Write and review Rails database migrations safely, including reversible changes, lock-aware operations, and rollout sequencing. Use when adding or changing schema, indexes, constraints, or backfills.
Use for schema changes and migration safety.
reversible blocks with explicit up/down SQL for data moves).table_exists? / column_exists? guards where migrations may run against varied states).execute "UPDATE ..." → tighten constraint); anything long-running moves out of the migration path entirely.Long-running or risky data backfills live in script/migrations/*.rb, run manually (e.g. via Kamal), not in the deploy migration window:
next if Entry.exists?(...)) so reruns are safe.find_each / in_batches), never one giant write.NOT NULL.find_each + update! up, update_all down.validates uniqueness (the validation races; the index doesn't).foreign_key: false on references) for DDL speed and shard-friendliness, keeping integrity in Rails. Either posture is fine — but make it consistent and documented, not accidental.singleton_guard column defaulting to 0 with a unique index.account.increment!(:cards_count) for sequence numbers + unique [account_id, number] index; a locked sequence row (first_or_create! under lock, increment!) for global ID sequences.[account_id, ...] composites in a dedicated migration phase; drop now-redundant single-column indexes and comment why.add_index :tags, [:account_id, :title], unique: true.migrations_paths and schema files.return if connection.adapter_name == "SQLite"), adapter-specific DDL (FTS5 vs sharded fulltext), and dual schema dumps (schema.rb / schema_sqlite.rb via per-config schema_dump).default_transaction_mode: immediate to reduce SQLITE_BUSY under concurrent writers.dump_schema_after_migration in production.Column replacement
Constraint hardening
Destructive changes
script/migrations/).validates uniqueness with no backing unique index.MOmorluto/rea486k8,943 new stars in the last 7 days
Diagnose hard bugs and performance regressions by building a feedback loop with tests or scripts.
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days
MAmattpocock/skills337k4,978 new stars in the last 7 days