Skip to content

Add staging S3 cleanup for Active Storage orphans after DB restores#1055

Open
leonardow-unep-wcmc wants to merge 2 commits into
developfrom
feature/clean-up-staging-s3-bucket-after-production-db-restore
Open

Add staging S3 cleanup for Active Storage orphans after DB restores#1055
leonardow-unep-wcmc wants to merge 2 commits into
developfrom
feature/clean-up-staging-s3-bucket-after-production-db-restore

Conversation

@leonardow-unep-wcmc
Copy link
Copy Markdown
Contributor

@leonardow-unep-wcmc leonardow-unep-wcmc commented May 13, 2026

Summary

  • Add a staging-only rake task and service to remove orphaned Active Storage objects from the staging S3 bucket after a production DB restore.
  • Use the current active_storage_blobs table as the source of truth and keep a restore cutoff based on the latest blob timestamp so newly replicated objects are preserved.
  • Log each dry-run candidate key so operators can review the exact deletion set before running for real.
  • Include coverage for the cleanup logic and the staging-only guardrail.

Testing

  • Added service specs for bucket pagination, dry-run output, cutoff handling, and environment restrictions.
  • Existing serializer and export specs were updated to keep coverage aligned with the current Active Storage and taxon concept changes.

@leonardow-unep-wcmc leonardow-unep-wcmc changed the base branch from master to develop May 13, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant