fix: Remove orphan members from inbox (#1797)
This commit is contained in:
parent
5daf970a87
commit
6bbeb005f5
2 changed files with 14 additions and 1 deletions
|
@ -0,0 +1,13 @@
|
|||
class RemoveOrphanInboxMembersFromInboxes < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
Account.all.map do |account|
|
||||
user_ids = account.users.all.map(&:id)
|
||||
inboxes = account.inboxes
|
||||
inboxes.each do |inbox|
|
||||
inbox.inbox_members.each do |inbox_member|
|
||||
inbox_member.destroy! unless user_ids.include?(inbox_member.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
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_02_12_154240) do
|
||||
ActiveRecord::Schema.define(version: 2021_02_17_154129) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_stat_statements"
|
||||
|
|
Loading…
Reference in a new issue