Allow ActionText embed reuse and safe purge (#2346)

This commit is contained in:
Jeremy Daer
2026-01-12 10:30:18 -08:00
committed by GitHub
parent 7c7b4eb621
commit 006e61ea58
4 changed files with 140 additions and 18 deletions
+4 -2
View File
@@ -10,17 +10,19 @@
#
# Safe to re-run: skips attachments that already have entries (by blob_id + recordable).
#
# IMPORTANT: Before running in production, verify zero historic blob reuse in tracked contexts:
# OPTIONAL: If you want to enforce no-reuse for direct attachments, verify there are
# no existing violations (ActionText embeds may legitimately reuse blobs):
#
# ActiveStorage::Attachment
# .joins(:blob)
# .where(record_type: Storage::TRACKED_RECORD_TYPES)
# .where.not(record_type: "ActionText::RichText")
# .where.not(active_storage_blobs: { account_id: Storage::TEMPLATE_ACCOUNT_ID })
# .select(:blob_id)
# .group(:blob_id)
# .having("COUNT(*) > 1")
# .count
# # Should return empty hash if no reuse exists in tracked contexts
# # Should return empty hash if no direct-attachment reuse exists
#
# If reuse exists (excluding template blobs), fix the data first.
class BackfillStorageLedger