[Backend] Add scheduled cron job to prune expired idempotency keys from database
Overview
The API uses idempotency keys to prevent duplicate transactions on stream creation. Without automatic retention cleanup, the idempotency table grows indefinitely.
Problem
- Unbounded growth in table size wastes database storage and degrades index performance over time.
Proposed Changes
- Add a scheduled cleanup task running every 24 hours (or node-cron in worker).
- Delete records where
createdAt < NOW() - INTERVAL '7 days'.
Acceptance Criteria
- [ ] Cron worker successfully deletes records older than retention period.
- [ ] Cleanups log count of pruned records.
- [ ] Unit test verifies records within retention window are preserved.
@Chinko21 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.
I would like to fix this
âšī¸ Repo Maintainers: To accept this application, review their application or assign @Chinko21 to this issue.
Congratulations, @Chinko21! đ Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.
đ§âđģ @Chinko21: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
đ¤ Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
đ Happy Wave đ
This issue has been marked as completed by a Drips Wave moderator for @Chinko21 as part of the Stellar Wave Program's 10th Wave đĨŗ
Moderator's reason: [Auto-assessed] The PR #1561 was merged by maintainers on 2026-10-09 as evidenced by the mergedAt timestamp. The contribution successfully adds the idempotency key model, migration, retention worker, and comprehensive unit tests fulfilling all requirements of issue #1495.
đ @Chinko21: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here.
đ§âđģ Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.
âšī¸ Note: This issue was marked complete via moderation. Points were issued even though the GitHub issue remains open.