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

20230914092224_synchronously_create_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: c0d1554e426f980be925009796b134db321f0729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

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

  TABLE_NAME = :vulnerability_occurrences
  INDEX_NAME = "tmp_index_vulnerability_occurrences_uuid_cast"

  def up
    disable_statement_timeout do
      execute <<~SQL
        CREATE INDEX CONCURRENTLY IF NOT EXISTS #{INDEX_NAME}
        ON #{TABLE_NAME}((uuid::uuid))
      SQL
    end
  end

  def down
    remove_concurrent_index_by_name(
      TABLE_NAME,
      INDEX_NAME
    )
  end
end