about summary refs log tree commit diff
path: root/db/post_migrate/20220310060722_optimize_null_index_accounts_moved_to_account_id.rb
blob: ec93a417a53ab53a33976d7b26f455d6ebd15a9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

require Rails.root.join('lib', 'mastodon', 'migration_helpers')

class OptimizeNullIndexAccountsMovedToAccountId < ActiveRecord::Migration[5.2]
  include Mastodon::MigrationHelpers

  disable_ddl_transaction!

  def up
    update_index :accounts, 'index_accounts_on_moved_to_account_id', :moved_to_account_id, where: 'moved_to_account_id IS NOT NULL'
  end

  def down
    update_index :accounts, 'index_accounts_on_moved_to_account_id', :moved_to_account_id
  end
end