summaryrefslogtreecommitdiff
path: root/db/post_migrate/20200323011955_remove_index_used_for_scan_migration.rb
blob: 0568cdb8483507530e6b95727d8688cfa5258b31 (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 RemoveIndexUsedForScanMigration < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'job_artifacts_secure_reports_temp_index'
  COLUMNS = [:id, :file_type, :job_id, :created_at, :updated_at]

  disable_ddl_transaction!

  def up
    if index_exists?(:ci_job_artifacts, COLUMNS, name: INDEX_NAME)
      remove_concurrent_index(:ci_job_artifacts, COLUMNS, name: INDEX_NAME)
    end
  end

  def down
    add_concurrent_index(:ci_job_artifacts,
                         COLUMNS,
                         name: INDEX_NAME,
                         where: 'file_type BETWEEN 5 AND 8')
  end
end