Files
RepoHub/scripts/migrations/002_add_last_seen_to_packages.sql
T
Yusuf İpek ea792a8a7f feat: add package pruning system with configurable grace periods
- Implemented automatic pruning of stale packages across all platform sync endpoints (Arch, AUR, Debian, Ubuntu, Fedora, Homebrew, Winget)
- Added `last_seen_at` tracking to mark packages as seen during sync runs and identify inactive packages
- Introduced `PRUNE_GRACE_DAYS` and `PRUNE_HARD_DELETE_DAYS` environment variables for configurable soft-delete and hard-delete thresholds
2025-11-13 01:54:23 +03:00

11 lines
444 B
SQL

-- Add last_seen_at to track soft-deletion by sync scope
ALTER TABLE packages
ADD COLUMN IF NOT EXISTS last_seen_at TIMESTAMPTZ;
-- Backfill existing rows so they are not immediately purged until their next scoped sync
UPDATE packages SET last_seen_at = NOW() WHERE last_seen_at IS NULL;
-- Helpful index for prune queries
CREATE INDEX IF NOT EXISTS idx_packages_seen_scope
ON packages (platform_id, repository, is_active, last_seen_at);