about summary refs log tree commit diff
path: root/db/migrate/20200721221659_backfill_conversation_visibility.rb
blob: 93394b825835fe8b72e07d92f23bcad052643263 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class BackfillConversationVisibility < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def up
    Rails.logger.info('Backfilling thread visibility...')

    safety_assured do
      execute('UPDATE conversations SET public = true FROM (SELECT account_id, conversation_id FROM statuses WHERE NOT reply AND visibility IN (0, 1)) AS s WHERE conversations.id = s.conversation_id')
    end
  end

  def down
    true
  end
end