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

20230320110802_add_index_to_vulnerability_findings_on_uuid.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6795a7ecbe74a10bf772be9a631636ba9a5247b6 (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 AddIndexToVulnerabilityFindingsOnUuid < Gitlab::Database::Migration[2.1]
  INDEX_NAME = 'index_vuln_findings_on_uuid_including_vuln_id'

  disable_ddl_transaction!

  # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/397740

  def up
    prepare_async_index_from_sql <<-SQL
      CREATE UNIQUE INDEX CONCURRENTLY #{INDEX_NAME} ON vulnerability_occurrences (uuid) include (vulnerability_id);
    SQL
  end

  def down
    unprepare_async_index_by_name(:vulnerability_occurrences, INDEX_NAME)
  end
end