chore: Delete related notifications if a conversation is deleted (#2592)
This commit is contained in:
@@ -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
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_06_23_155413) do
|
||||
ActiveRecord::Schema.define(version: 2021_07_08_140842) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
|
||||
Reference in New Issue
Block a user