From 3e5c4f1640b5e0c1d9b882f26bd92bfec189fb75 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 21 Sep 2026 12:22:50 +0000 Subject: [PATCH] Fix `PreviewCardsStatus` records not being deleted on account deletion (#40624) --- app/services/batched_remove_status_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb index 4dad80fc11b..7cd4021a7c5 100644 --- a/app/services/batched_remove_status_service.rb +++ b/app/services/batched_remove_status_service.rb @@ -33,6 +33,9 @@ class BatchedRemoveStatusService < BaseService # cascade the delete faster without loading the associations. statuses_and_reblogs.each_slice(50) { |slice| Status.unscoped.where(id: slice.pluck(:id)).delete_all } + # TODO: remove later, when we have added appropriate foreign keys + PreviewCardsStatus.where(status_id: statuses_and_reblogs.pluck(:id)).in_batches.delete_all + # Since we skipped all callbacks, we also need to manually # deindex the statuses if Chewy.enabled?