Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20231122114135_add_index_on_sbom_occurrences_highest_severity.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c7c5aef71605013a4961e7d402c04d838559ee59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class AddIndexOnSbomOccurrencesHighestSeverity < Gitlab::Database::Migration[2.2]
  disable_ddl_transaction!
  milestone '16.7'

  INDEX_NAME = 'index_sbom_occurrences_on_highest_severity'
  INDEX_TO_BE_REMOVED = 'index_sbom_occurrences_on_project_id'

  def up
    add_concurrent_index :sbom_occurrences,
      [:project_id, :highest_severity],
      order: { highest_severity: 'DESC NULLS LAST' },
      name: INDEX_NAME

    remove_concurrent_index_by_name :sbom_occurrences, INDEX_TO_BE_REMOVED
  end

  def down
    add_concurrent_index :sbom_occurrences, :project_id, name: INDEX_TO_BE_REMOVED
    remove_concurrent_index_by_name :sbom_occurrences, INDEX_NAME
  end
end