20190519130537_remove_boosts_widening_audience.rb 668 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class RemoveBoostsWideningAudience < ActiveRecord::Migration[5.2]
  3. disable_ddl_transaction!
  4. def up
  5. public_boosts = Status.find_by_sql(<<-SQL.squish)
  6. SELECT boost.id
  7. FROM statuses AS boost
  8. LEFT JOIN statuses AS boosted ON boost.reblog_of_id = boosted.id
  9. WHERE
  10. boost.id > 101746055577600000
  11. AND (boost.local = TRUE OR boost.uri IS NULL)
  12. AND boost.visibility IN (0, 1)
  13. AND boost.reblog_of_id IS NOT NULL
  14. AND boosted.visibility = 2
  15. SQL
  16. RemovalWorker.push_bulk(public_boosts.pluck(:id))
  17. end
  18. def down
  19. raise ActiveRecord::IrreversibleMigration
  20. end
  21. end