summaryrefslogtreecommitdiff
path: root/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb
blob: 2134131b28f17d10754fcdd9bcc1bee3d7d4750e (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 AddIndexesToCiBuildsAndPipelines < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_concurrent_index :ci_pipelines, [:project_id, :ref, :id], order: { id: :desc }
    add_concurrent_index :ci_builds, [:commit_id, :artifacts_expire_at, :id], where: "type = 'Ci::Build' AND (retried = false OR retried IS NULL) AND name IN ('sast', 'dependency_scanning', 'sast:container', 'container_scanning', 'dast')"
  end

  def down
    remove_concurrent_index :ci_pipelines, [:project_id, :ref, :id], order: { id: :desc }
    remove_concurrent_index :ci_builds, [:commit_id, :artifacts_expire_at, :id], where: "type = 'Ci::Build' AND (retried = false OR retried IS NULL) AND name IN ('sast', 'dependency_scanning', 'sast:container', 'container_scanning', 'dast')"
  end
end