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

20220523171107_drop_deploy_tokens_token_column.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 79a145bc466326347f1cb2b5d55086f233bbdafa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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