Skip to content

Daily cleanup cron for old D1 data - #29

Merged
valeboth merged 1 commit into
mainfrom
feat/cleanup-cron
Aug 26, 2026
Merged

Daily cleanup cron for old D1 data#29
valeboth merged 1 commit into
mainfrom
feat/cleanup-cron

Conversation

@valeboth

Copy link
Copy Markdown
Owner

Keeps D1 tidy without manual work.

  • Cron Trigger (wrangler.toml: 0 4 * * *, daily 04:00 UTC) + a scheduled handler.
  • lib/cleanup.ts: batch-deletes rooms older than 30 days (and their swipes/matches — not relying on FK cascade), then orphaned users + profiles.
  • Default export is now { fetch, scheduled }; the Room DO export is unchanged.

Rooms are ephemeral, so 30 days is plenty. Cron Triggers are on the free tier; a daily run is negligible.

Validated the cleanup SQL against local D1 (5 statements OK). lint/typecheck/build ✅. health → v3.7.

- Cron Trigger (wrangler.toml: 04:00 UTC daily) + scheduled handler in index.ts
- lib/cleanup.ts: batch-delete rooms older than 30 days (+ their swipes/matches),
  then orphaned users and profiles
- default export now { fetch, scheduled }; Room export unchanged
- health -> v3.7

Validated the cleanup SQL against local D1 (5 statements OK).
@valeboth
valeboth merged commit d4a9784 into main Aug 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant