2021-07-12 06:58:16 +00:00
|
|
|
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|
|
2021-10-14 08:27:01 +00:00
|
|
|
deleted_ids << (id_list - Conversation.where(id: id_list).pluck(:id))
|
2021-07-12 06:58:16 +00:00
|
|
|
end
|
|
|
|
Notification.where(primary_actor_type: 'Conversation', primary_actor_id: deleted_ids).destroy_all
|
|
|
|
end
|
|
|
|
end
|