-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Remove entities no longer in manifest
class OrphanCleanup
def cleanup(manifest)
external_file_ids = manifest.dig_all("providers", "topics", "files", "id")
external_topic_ids = manifest.dig_all("providers", "topics", "id")
external_provider_ids = manifest["providers"].pluck("id")
external_tag_ids = manifest["tags"].pluck("id")
# ActiveStorage will purge attached blobs automatically
TopicFile.where.not(external_id: external_file_ids).destroy_all
Topic.where.not(external_id: external_topic_ids).destroy_all
ContentProvider.where.not(external_id: external_provider_ids).destroy_all
Tag.where.not(external_id: external_tag_ids).destroy_all
end
end