summaryrefslogtreecommitdiff
path: root/db/migrate/20190530154715_add_index_to_merge_requests_state_and_merge_status.rb
blob: e669f81ca35fa74440ba1b7afa84fc738577c622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class AddIndexToMergeRequestsStateAndMergeStatus < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :merge_requests, [:state, :merge_status],
                         where: "state = 'opened' AND merge_status = 'can_be_merged'"
  end

  def down
    remove_concurrent_index :merge_requests, [:state, :merge_status]
  end
end