feat(retention): data-retention purge#86
Merged
Merged
Conversation
Port data retention from the reference. Adds a RetentionService that purges attachments and audit logs older than the configured retention policy (settings retention_attachments / retention_audit_logs, mapped via the shared day map: 90_days/180_days/365_days/1_year/2_years/3_years/5_years). Closed-ticket retention is reported only, not enforced — that needs a soft-delete grace period (a deleted_at column the schema lacks), matching the Phoenix purge task. Exposes POST /admin/data-retention/purge (admin-gated, ?dry_run=1 to report without deleting) in both routers. Pure day-map/cutoff helpers are unit- tested; PurgeExpired is covered against a real SQLite store.
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.
Ports data retention to Go, mirroring the Phoenix
escalated.purge_expiredtask and the Laravelescalated:purge-expiredcommand.What
RetentionService— purges attachments + audit logs older than the configured retention policy (retention_attachments/retention_audit_logssettings → shared day map:90_days/180_days/365_days/1_year/2_years/3_years/5_years;never/unknown = disabled).deleted_atcolumn the schema lacks). Matches the Phoenix behavior and ties into the closed-ticket-purge decision (feat(email): add services/email.MessageIdUtil for RFC 5322 + signed Reply-To #27).POST /admin/data-retention/purge(admin-gated) in both routers.?dry_run=1reports counts without deleting.Verification
go build ./...clean; new files 0golangci-lintissues (the 6 reported are pre-existing inchat_session_service_test.go; only-new-issues mode ignores them).TestRetentionDays/TestRetentionCutoff(pure) +TestPurgeExpired(real SQLite: dry-run reports without deleting, real run deletes only the expired row).go test ./...passes.