fix(db): skip updated_at and stats bookkeeping in audit_logs

Merged
RI
3mo ago
+494-0

Summary (AI generated)

  • Skip audit_logs writes when an UPDATE only touches updated_at on any audited table
  • Keep apps/orgs stats refresh bookkeeping silent (stats_updated_at / stats_refresh_requested_at + updated_at)
  • Delete matching historical noise rows in bounded batches during migration

Motivation (AI generated)

Stats refresh and pure updated_at bumps were polluting audit_logs with bookkeeping noise that has no user-facing audit value and wastes TOAST/WAL on Capgo-EU.

Business Impact (AI generated)

Smaller, clearer org audit feeds and less storage/WAL pressure from high-frequency dashboard/stats bookkeeping writes.

Test Plan (AI generated)

  • bun run supabase:with-env -- bunx vitest run tests/audit-logs.test.ts tests/chart-refresh-rpc.test.ts
  • Confirm migration applies on a fresh local reset
  • Spot-check prod after deploy: no new updated_at-only / stats-only UPDATE rows in audit_logs

Generated with AI

Made with Cursor


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Reduced audit log noise from routine timestamp, statistics, counter, and internal bookkeeping updates.
    • Prevented large version-related details from being stored in audit records.
    • Preserved relevant actor and record information for meaningful audit events.
    • Cleaned up matching historical audit entries in manageable batches.