summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200217223651_add_index_to_job_artifact_secure_reports.rb
blob: ca297272f8e0a3bb68b344c60d3e241da18d3fb3 (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 AddIndexToJobArtifactSecureReports < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'job_artifacts_secure_reports_temp_index'
  PARTIAL_FILTER = "file_type BETWEEN 5 AND 8"

  disable_ddl_transaction!

  def up
    # This is a temporary index used for the migration of Security Reports to Security Scans
    add_concurrent_index(:ci_job_artifacts,
                         [:id, :file_type, :job_id, :created_at, :updated_at],
                         name: INDEX_NAME,
                         where: PARTIAL_FILTER)
  end

  def down
    remove_concurrent_index(:ci_job_artifacts,
                            [:id, :file_type, :job_id, :created_at, :updated_at])
  end
end