about summary refs log tree commit diff
path: root/db/migrate/20200921030158_backfill_curated_statuses.rb
blob: f9bf32afb1660becdc6f2e67bc0ae5d0c994383e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class BackfillCuratedStatuses < ActiveRecord::Migration[5.2]
  disable_ddl_transaction!

  def up
    Status.with_public_visibility.joins(:status_stat).where('favourites_count != 0 OR reblogs_count != 0').in_batches.update_all(curated: true)
    Status.with_public_visibility.where(curated: false).left_outer_joins(:bookmarks).where.not(bookmarks: { status_id: nil }).in_batches.update_all(curated: true)
  end

  def down
    nil
  end
end