summaryrefslogtreecommitdiff
path: root/db/migrate/20201028160831_add_temporary_index_to_vulnerabilities_table.rb
blob: 05bb75be75a6ed948354f770a9b46412638519a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

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

  DOWNTIME = false
  INDEX_NAME = 'temporary_index_vulnerabilities_on_id'

  disable_ddl_transaction!

  def up
    add_concurrent_index :vulnerabilities, :id, where: "state = 2 AND (dismissed_at IS NULL OR dismissed_by_id IS NULL)", name: INDEX_NAME
  end

  def down
    remove_concurrent_index_by_name :vulnerabilities, INDEX_NAME
  end
end