summaryrefslogtreecommitdiff
path: root/db/migrate/20200528125905_add_project_id_user_id_status_ref_index_to_ci_pipelines.rb
blob: 7211490e3372654f8149cc544644614f61bd3ea7 (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
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  SOURCE_PARENT_PIPELINE = 12

  def up
    add_concurrent_index(
      :ci_pipelines,
      [:project_id, :user_id, :status, :ref],
      where: "source != #{SOURCE_PARENT_PIPELINE}"
    )
  end

  def down
    remove_concurrent_index(
      :ci_pipelines,
      [:project_id, :user_id, :status, :ref],
      where: "source != #{SOURCE_PARENT_PIPELINE}"
    )
  end
end