summaryrefslogtreecommitdiff
path: root/db/migrate/20191205094702_add_index_for_cross_projects_dependencies_to_ci_builds.rb
blob: 023414fb4bb69f060ab3531c4c10f8cba909d50c (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 AddIndexForCrossProjectsDependenciesToCiBuilds < ActiveRecord::Migration[5.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :ci_builds, [:project_id, :name, :ref],
      where: "type = 'Ci::Build' AND status = 'success' AND (retried = FALSE OR retried IS NULL)"
  end

  def down
    remove_concurrent_index :ci_builds, [:project_id, :name, :ref],
      where: "type = 'Ci::Build' AND status = 'success' AND (retried = FALSE OR retried IS NULL)"
  end
end