🧠 HeyCMO
Workflows

Events Cleanup

Periodic cleanup of stale event data to maintain database performance.

Events Cleanup Workflow

The Events Cleanup workflow is a maintenance workflow that periodically removes old event records from the database to keep storage lean and query performance fast.

How It Works

  1. Read Retention Policy — Accepts a configurable retention period (default: 90 days)
  2. Delete Old Events — Removes all events older than the retention window from PostgreSQL
  3. Report Results — Returns count of deleted events and the retention period used

Input Schema

{
  retentionDays?: number;  // Default: 90
}

Output

{
  deletedCount: number;   // Number of events deleted
  retentionDays: number;  // Retention period used
}

Graceful Degradation

If the database is unreachable (e.g., running in agent-only context), the workflow logs a warning and returns deletedCount: 0 instead of crashing.

Scheduling

Runs automatically via Inngest cron job. Not typically invoked manually.

On this page