blob: 595fd8e526bbcb4e4d8e31080b2cd90f2065862c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class BackfillAccountIdOnConversations < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
Rails.logger.info('Backfilling owners of conversation threads...')
safety_assured do
Conversation.left_outer_joins(:statuses).where(statuses: { id: nil }).in_batches.destroy_all
execute('UPDATE conversations SET account_id = s.account_id FROM (SELECT account_id, conversation_id FROM statuses WHERE NOT reply) AS s WHERE conversations.id = s.conversation_id')
end
end
def down
true
end
end
|