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

class AddMergeRequestsIndexOnTargetProjectAndBranch < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :merge_requests, [:target_project_id, :target_branch],
      where: "state_id = 1 AND merge_when_pipeline_succeeds = true"
  end

  def down
    remove_concurrent_index :merge_requests, [:target_project_id, :target_branch]
  end
end