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

20230913100953_create_supporting_index_for_uuid_type_casting.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 232aca06bb260b235da61bca70e1df966684b709 (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 CreateSupportingIndexForUuidTypeCasting < Gitlab::Database::Migration[2.1]
  TABLE_NAME = :vulnerability_occurrences
  INDEX_NAME = "tmp_index_vulnerability_occurrences_uuid_cast"

  def up
    index_sql = <<~SQL
      CREATE INDEX CONCURRENTLY #{INDEX_NAME}
      ON #{TABLE_NAME}((uuid::uuid))
    SQL

    # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/425037
    prepare_async_index_from_sql(index_sql)
  end

  def down
    unprepare_async_index_by_name(
      TABLE_NAME,
      INDEX_NAME
    )
  end
end