chore(ingest): drop webhook_events.payload and retire its pruner

Merged
SA
3mo ago
+7029-102

The contract half of the split started in #6749.

Every writer is now on the build that sends bodies to ingest.webhook_payloads — verified in production: 2,849 rows in today's partition, DEFAULT empty, zero webhook errors. So webhook_events.payload holds only rows received before that deploy, and nothing reads it back.

What goes

  • The column. Migration 0090, a single ALTER TABLE ... DROP COLUMN.
  • apps/api/src/app/api/ingest/prune-payloads. Its entire job was nulling this column to cap growth. Retention is a DROP of a day partition now, which returns space instead of leaving dead tuples.
  • Its QStash schedule, removed before this merges, so nothing calls a route whose query references a column that's going away.

This does not shrink the database

Verified on a fresh copy of production (532 GB, 102.1M rows):

before:  532 GB, payload column present
ALTER TABLE ... DROP COLUMN     50ms
after:   532 GB, payload column gone

DROP COLUMN is catalog-only. The 424 GB of dead TOAST is reclaimed by a rewrite, which is the us-east-1 restore. What changes here is that the restore no longer has a column to carry across.

Also verified on that copy: the dedup upsert on (provider, event_id) still works with the column gone.

Deliberate data loss

Bodies for events received in the ~7 days before #6749 deployed existed only in this column and are discarded. That's intentional — the schema comment has always said nothing reads them back, and retention would have dropped them anyway. Flagged and confirmed before doing it.

Testing

  • Lint, typecheck pass
  • Migration and the dedup path both executed against a real production copy, not a fixture

https://claude.ai/code/session_014D6wif8HDRCXEFf5Ku4w7V


Summary by cubic

Drops ingest.webhook_events.payload and removes the pruner route now that all writers store bodies in ingest.webhook_payloads. Previously bodies lived in payload and a cron nulled old rows; now retention is partition drops and the legacy column is gone.

  • Migration 0090_webhook_events_drop_payload drops the column; ensure all writers are on the new build before applying.
  • Remove the QStash schedule calling /api/ingest/prune-payloads (already disabled) and delete the pruner route.
  • Expected data loss: legacy payloads that only existed in webhook_events.payload are discarded; nothing reads them back.
  • DB size will not shrink immediately; DROP COLUMN is catalog-only and space is reclaimed on the next table rewrite/restore.
  • Dedup upsert on (provider, event_id) remains unchanged and verified.

Summary by CodeRabbit

  • Removed Features

    • Removed the payload-pruning API endpoint and its pruning statistics response.
    • Removed legacy webhook payload data from webhook event records.
  • Data Updates

    • Webhook payloads are now represented through the dedicated payload storage system.
    • Updated webhook event data structures to exclude the legacy payload field.