Repository navigation
feat(retention): add per-table retention policies - #776
Closed
EmmanuelOchaje wants to merge 1 commit into
Closed
EmmanuelOchaje wants to merge 1 commit into
EmmanuelOchaje wants to merge 1 commit into
Conversation
Add a `policies` map with per-table retention periods (webhook_delivery, session, audit_logs, temp_files), each overridable via env var, and a `getRetentionDays` helper. Existing delivery/session constants and exports are unchanged. Closes SmartDropLabs#685
|
@EmmanuelOchaje Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Superseded by #777, which combines this change with the other SmartDrop fixes into one PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds per-table data retention policies to
src/services/dataRetention.jsso retention periods are no longer global-only.What changed
policiesmap keyed by table:webhook_delivery,session,audit_logs(default 90 days),temp_files(default 7 days).DELIVERY_LOG_RETENTION_DAYS,SESSION_RETENTION_DAYS,AUDIT_LOG_RETENTION_DAYS,TEMP_FILE_RETENTION_DAYS. Invalid values fall back to the default.getRetentionDays(table)helper.applyDeliveryRetentionandapplySessionRetentionnow read their period frompolicies.policiesandgetRetentionDaysare exported. Existing exports (DELIVERY_RETENTION_DAYS,SESSION_RETENTION_DAYS, TTL constants, and functions) are unchanged.Why
Retention was not configurable per table, which led to over-deletion of data that should be kept and under-deletion of stale data, with compliance risk.
Notes
SESSION_RETENTION_DAYSkeeps its existing default of 7 days to avoid changing current behavior. The issue's example suggested 30; changing that is a separate decision.audit_logsandtemp_fileshave no Redis key prefix infindExpired()yet, so their policies are defined but not yet applied to any cleanup scan. Adding scans for them would delete data and should be a follow-up.How to test
npx eslint src/services/dataRetention.js.require('./src/services/dataRetention').policiesshould show the defaults (30, 7, 90, 7).AUDIT_LOG_RETENTION_DAYS=365and confirmgetRetentionDays('audit_logs')returns 365.Closes #685