-
Database
Set up data retention and cleanup jobs
Adds scheduled cleanup for expired sessions, stale tokens, old logs, and abandoned records so tables don't grow forever.
Free Prompt
Set up data cleanup jobs for my app. Inventory the tables or collections that grow unbounded: sessions, password reset tokens, email verification tokens, magic link tokens, logs, webhook event records, abandoned carts, expired invites, soft-deleted rows.
For each, add a scheduled cleanup that deletes rows past a sensible retention window: sessions and tokens expire within hours or days, logs keep weeks, soft deletes purge after a grace period. Run them in small batches with LIMIT so the cleanup itself doesn't lock tables, and schedule them at low-traffic times. Log what each run deleted so the job is auditable.
Don't delete anything tied to money or legal obligations: payment records, invoices, and audit trails stay. If a record type has regulatory retention requirements in my domain, flag it instead of guessing. Use whatever scheduling mechanism already exists in the stack (cron, platform scheduled functions, or a worker); don't add a new service.
Deliver: the retention policy per data type with reasoning, the cleanup jobs and schedule, and verification: insert expired test rows, run a cleanup, confirm they're gone and recent rows survive.
What This Does / How This Helps
Adds scheduled jobs that delete data past its useful life so your tables stay small, fast, and cheap to back up. Every vibe-coded app grows junk tables: reset tokens from six months ago, dead sessions, webhook receipts nobody reads. None of it breaks anything, so it never gets cleaned, and a year later the sessions table has two million rows and every query on it is slower than it should be. Retention is also a privacy win: storing less old user data means less to leak and less to hand over on a deletion request.
Want to skip doing this by hand?
Fortivibe audits your app for all of the areas these prompts cover (and more).