Problem
Two tables grow without bound:
AuditLog — every admin mutation logs here (per ADR-014). No TTL, no partitioning, no archival strategy.
ProcessedWebhook — PayMongo webhook idempotency log. Old entries (>30 days) serve no purpose but accumulate forever.
Impact
- Slow queries on
AuditLog as row count grows (admin dashboard, analytics)
ProcessedWebhook becomes noise — idempotency window is hours, not months
- Storage costs on Neon increase monotonically
Suggested Fix
ProcessedWebhook: Add a scheduled cleanup job (e.g., Vercel cron or a script) that deletes rows older than 30 days.
AuditLog: Two options:
- Partition by month (Postgres native partitioning) — keeps queries fast, old partitions can be detached/archived
- Archive + truncate — export to cold storage, then delete rows older than 12 months
Either way, add a createdAt-based TTL policy.
References
prisma/schema.prisma lines 816-833 (AuditLog)
prisma/schema.prisma lines 762-779 (ProcessedWebhook)
AGENTS.md rule 5: Every admin action logs to AuditLog
Severity: Consider — operational debt, not urgent but compounds over time
Problem
Two tables grow without bound:
AuditLog— every admin mutation logs here (per ADR-014). No TTL, no partitioning, no archival strategy.ProcessedWebhook— PayMongo webhook idempotency log. Old entries (>30 days) serve no purpose but accumulate forever.Impact
AuditLogas row count grows (admin dashboard, analytics)ProcessedWebhookbecomes noise — idempotency window is hours, not monthsSuggested Fix
ProcessedWebhook: Add a scheduled cleanup job (e.g., Vercel cron or a script) that deletes rows older than 30 days.
AuditLog: Two options:
Either way, add a
createdAt-based TTL policy.References
prisma/schema.prismalines 816-833 (AuditLog)prisma/schema.prismalines 762-779 (ProcessedWebhook)AGENTS.mdrule 5: Every admin action logs to AuditLogSeverity: Consider — operational debt, not urgent but compounds over time