summaryrefslogtreecommitdiff
path: root/db/post_migrate/20230511132140_create_component_id_index.rb
blob: 3b466010f7c8ffdd5b7246d56127d1ec17209253 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# frozen_string_literal: true

class CreateComponentIdIndex < Gitlab::Database::Migration[2.1]
  disable_ddl_transaction!

  INDEX_NAME = 'index_sbom_occurrences_on_project_id_component_id'

  def up
    return if index_exists_by_name?(:sbom_occurrences, INDEX_NAME)

    add_concurrent_index :sbom_occurrences, [:project_id, :component_id], name: INDEX_NAME
  end

  def down
    remove_concurrent_index_by_name :sbom_sources, INDEX_NAME
  end
end