summaryrefslogtreecommitdiff
path: root/db/migrate/20200323122201_add_index_on_user_and_created_at_to_ci_builds.rb
blob: d0f630345023ac95ca6535db746d22ed67723432 (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 AddIndexOnUserAndCreatedAtToCiBuilds < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  INDEX_NAME = 'index_ci_builds_on_user_id_and_created_at_and_type_eq_ci_build'

  def up
    add_concurrent_index :ci_builds, [:user_id, :created_at], where: "type = 'Ci::Build'", name: INDEX_NAME
  end

  def down
    remove_concurrent_index_by_name :ci_builds, INDEX_NAME
  end
end