summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200528123703_add_merge_request_partial_index_to_events.rb
blob: bf2269e77ab33d5366bf54567862b3dcbd7d6e22 (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
# frozen_string_literal: true

class AddMergeRequestPartialIndexToEvents < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  INDEX_NAME = 'index_events_on_author_id_and_created_at_merge_requests'

  def up
    add_concurrent_index(
      :events,
      [:author_id, :created_at],
      name: INDEX_NAME,
      where: "(target_type = 'MergeRequest')"
    )
  end

  def down
    remove_concurrent_index :events, INDEX_NAME
  end
end