diff options
Diffstat (limited to 'db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb')
-rw-r--r-- | db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb b/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb new file mode 100644 index 00000000000..79a145bc466 --- /dev/null +++ b/db/post_migrate/20220523171107_drop_deploy_tokens_token_column.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +class DropDeployTokensTokenColumn < Gitlab::Database::Migration[2.0] + disable_ddl_transaction! + + COMPOSITE_INDEX_NAME = 'index_deploy_tokens_on_token_and_expires_at_and_id' + + def up + remove_column :deploy_tokens, :token + end + + def down + unless column_exists?(:deploy_tokens, :token) + add_column :deploy_tokens, :token, :string + end + + add_concurrent_index(:deploy_tokens, :token, unique: true) + add_concurrent_index(:deploy_tokens, %i[token expires_at id], where: 'revoked IS FALSE', name: COMPOSITE_INDEX_NAME) + end +end |