Problem
When imports misbehave in prod ("why did 10 rows silently drop?"), the first thing anyone wants is the exact SQL the gem ran. Right now you have to attach a debugger or subscribe to AR's notification channel.
Proposal
StagingTable.stage(User, log_sql: true) { |s| s.insert(rows) }
# → [staging_table] SQL: CREATE TEMP TABLE staging_users_abc123 ...
# → [staging_table] SQL: INSERT INTO staging_users_abc123 (...) VALUES ...
# → [staging_table] SQL: INSERT INTO users (...) SELECT ... FROM staging_users_abc123 ON CONFLICT ...
- Emits via the configured logger
- Truncates very long VALUES lists (
...)
- Global enable via config
Acceptance criteria
log_sql: true per-call works
config.log_sql = true enables globally
- Sensitive values masked if
config.mask_columns = [:password_digest, :ssn]
- Pairs with the logger-integration issue
Problem
When imports misbehave in prod ("why did 10 rows silently drop?"), the first thing anyone wants is the exact SQL the gem ran. Right now you have to attach a debugger or subscribe to AR's notification channel.
Proposal
...)Acceptance criteria
log_sql: trueper-call worksconfig.log_sql = trueenables globallyconfig.mask_columns = [:password_digest, :ssn]