Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20180524132016_merge_requests_target_id_iid_state_partial_index.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bff4690427ed66d0a8a9ee70bc03b44307d1f603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class MergeRequestsTargetIdIidStatePartialIndex < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

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

  INDEX_NAME = 'index_merge_requests_on_target_project_id_and_iid_opened'

  disable_ddl_transaction!

  def up
    # On GitLab.com this index will take up roughly 5 MB of space.
    add_concurrent_index(
      :merge_requests,
      [:target_project_id, :iid],
      where: "state = 'opened'",
      name: INDEX_NAME
    )
  end

  def down
    remove_concurrent_index_by_name(:merge_requests, INDEX_NAME)
  end
end