chore: Delete related notifications if a conversation is deleted (#2592)

This commit is contained in:
Muhsin Keloth
2021-07-12 12:28:16 +05:30
committed by GitHub
parent 5726447e47
commit ba547b3f60
4 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
class RemoveNotificationsWithoutPrimaryActor < ActiveRecord::Migration[6.0]
def change
deleted_ids = []
Notification.where(primary_actor_type: 'Conversation').pluck(:primary_actor_id).uniq.each_slice(1000) do |id_list|
deleted_ids << id_list - Conversation.where(id: id_list).pluck(:id)
end
Notification.where(primary_actor_type: 'Conversation', primary_actor_id: deleted_ids).destroy_all
end
end