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

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

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

  INDEX_NAME = 'index_vulnerability_reads_on_location_image_trigram'
  REPORT_TYPES = { container_scanning: 2, cluster_image_scanning: 7 }.freeze

  def up
    add_concurrent_index :vulnerability_reads, :location_image,
      name: INDEX_NAME,
      using: :gin, opclass: { location_image: :gin_trgm_ops },
      where: "report_type = ANY (ARRAY[#{REPORT_TYPES.values.join(', ')}]) AND location_image IS NOT NULL"
  end

  def down
    remove_concurrent_index_by_name :vulnerability_reads, INDEX_NAME
  end
end