about summary refs log tree commit diff
path: root/db/post_migrate/20190519130537_remove_boosts_widening_audience.rb
blob: d2d924239229d3ce68afd9d794748528c92ce000 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class RemoveBoostsWideningAudience < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def up
    public_boosts = Status.find_by_sql(<<-SQL)
      SELECT boost.id
      FROM statuses AS boost
      LEFT JOIN statuses AS boosted ON boost.reblog_of_id = boosted.id
      WHERE
        boost.id > 101746055577600000
        AND (boost.local = TRUE OR boost.uri IS NULL)
        AND boost.visibility IN (0, 1)
        AND boost.reblog_of_id IS NOT NULL
        AND boosted.visibility = 2
    SQL

    RemovalWorker.push_bulk(public_boosts.pluck(:id))
  end

  def down
    raise ActiveRecord::IrreversibleMigration
  end
end