Add non-semver version retention policy #45

Merged
qwc merged 4 commits from feature/retention-policy into main 2026-02-04 19:46:27 +01:00
Owner

Summary

Closes #34

  • Time-based retention for non-semver versions: versions older than N days are automatically deleted
  • Semver versions are always kept indefinitely
  • Per-project retention_days column (nullable, NULL = use global default)
  • Global retention.nonsemver_days config setting (env: ASIAKIRJAT_RETENTION_NONSEMVER_DAYS)
  • Default: 0 (unlimited — no auto-deletion)
  • Background goroutine runs cleanup every hour and once at startup
  • Immediate cleanup after each new non-semver upload
  • Admin UI field on project edit page with placeholder showing global default

Test plan

  • Upload a non-semver version, set project retention to 1 day → version deleted by background worker
  • Upload semver versions → all kept regardless of retention setting
  • Set global default to 14 days, project override to 7 → project uses 7
  • Leave project override empty → falls back to global default
  • Upload non-semver version to project with retention → immediate cleanup of expired versions
  • go test ./... passes
  • Binary builds successfully

🤖 Generated with Claude Code

## Summary Closes #34 - Time-based retention for non-semver versions: versions older than N days are automatically deleted - Semver versions are always kept indefinitely - Per-project `retention_days` column (nullable, NULL = use global default) - Global `retention.nonsemver_days` config setting (env: `ASIAKIRJAT_RETENTION_NONSEMVER_DAYS`) - Default: 0 (unlimited — no auto-deletion) - Background goroutine runs cleanup every hour and once at startup - Immediate cleanup after each new non-semver upload - Admin UI field on project edit page with placeholder showing global default ## Test plan - [ ] Upload a non-semver version, set project retention to 1 day → version deleted by background worker - [ ] Upload semver versions → all kept regardless of retention setting - [ ] Set global default to 14 days, project override to 7 → project uses 7 - [ ] Leave project override empty → falls back to global default - [ ] Upload non-semver version to project with retention → immediate cleanup of expired versions - [ ] `go test ./...` passes - [ ] Binary builds successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Add exported IsSemver() function to docs package for checking whether a
version tag matches semver. Add RetentionConfig with nonsemver_days
setting to config, supporting env var ASIAKIRJAT_RETENTION_NONSEMVER_DAYS.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Migration 006 adds nullable retention_days column to projects table
for per-project retention policy override. Update Project model and
SQL store queries to include the new column.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Admin project edit form now shows a retention_days field with
placeholder indicating the global default. Create project also
accepts the field. Empty = use global default, 0 = unlimited.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add retention enforcement and background cleanup
All checks were successful
CI / test (pull_request) Successful in 1m11s
CI / build (pull_request) Successful in 58s
CI / docker (pull_request) Has been skipped
36973c623e
New retention worker runs hourly (and once at startup) to delete
non-semver versions older than the configured retention period.
Also triggers after each new non-semver upload for immediate cleanup.

Deletion follows existing pattern: DB record, filesystem, search
index, then cache invalidation. Semver versions are always kept.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
qwc merged commit d20ce87431 into main 2026-02-04 19:46:27 +01:00
qwc deleted branch feature/retention-policy 2026-02-04 19:46:27 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
qwc-open/asiakirjat!45
No description provided.