diff options
Diffstat (limited to 'db/post_migrate/20230914092224_synchronously_create_index_for_uuid_type_casting.rb')
-rw-r--r-- | db/post_migrate/20230914092224_synchronously_create_index_for_uuid_type_casting.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/db/post_migrate/20230914092224_synchronously_create_index_for_uuid_type_casting.rb b/db/post_migrate/20230914092224_synchronously_create_index_for_uuid_type_casting.rb new file mode 100644 index 00000000000..c0d1554e426 --- /dev/null +++ b/db/post_migrate/20230914092224_synchronously_create_index_for_uuid_type_casting.rb @@ -0,0 +1,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 |