Skip to content

Audit log retention purge job #41

@jusso-dev

Description

@jusso-dev

Follow-up to #4.

The audit_log table and per-tenant organisations.audit_retention_days column (default 395) ship in #4, but the actual purge job is out of scope for that PR.

Scope

  • Recurring job (Inngest / cron via instrumentation.ts) that deletes audit_log rows where created_at < now() - organisations.audit_retention_days * interval '1 day', grouped per organisation.
  • Run nightly (overnight AU). Surface per-org counts via structured logs.
  • Respect retention overrides — never delete rows newer than the org's configured window.
  • Test: create rows then advance retention boundary to confirm purge correctness.

Acceptance

  • Job is registered and runs on the schedule.
  • Deletion is batched (e.g. 10k rows per statement) so it does not lock the table.
  • Operator-visible metric: rows purged per org per run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions