diff options
Diffstat (limited to 'db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb')
-rw-r--r-- | db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb b/db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb new file mode 100644 index 00000000000..c330ece1a60 --- /dev/null +++ b/db/post_migrate/20221206132610_add_unique_token_encrypted_partition_id_index_to_ci_build.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddUniqueTokenEncryptedPartitionIdIndexToCiBuild < Gitlab::Database::Migration[2.1] + TABLE_NAME = :ci_builds + INDEX_NAME = :index_ci_builds_on_token_encrypted_partition_id_unique + COLUMNS = %i[token_encrypted partition_id].freeze + + def up + prepare_async_index( + TABLE_NAME, + COLUMNS, + where: 'token_encrypted IS NOT NULL', + unique: true, + name: INDEX_NAME + ) + end + + def down + unprepare_async_index(TABLE_NAME, COLUMNS, name: INDEX_NAME) + end +end |