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

20210420012909_index_cluster_agent_tokens_on_last_used_at.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c1715d8ac2933f154cff2440db0386017542df50 (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 IndexClusterAgentTokensOnLastUsedAt < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  OLD_INDEX = 'index_cluster_agent_tokens_on_agent_id'
  NEW_INDEX = 'index_cluster_agent_tokens_on_agent_id_and_last_used_at'

  disable_ddl_transaction!

  def up
    add_concurrent_index :cluster_agent_tokens, 'agent_id, last_used_at DESC NULLS LAST', name: NEW_INDEX
    remove_concurrent_index_by_name :cluster_agent_tokens, OLD_INDEX
  end

  def down
    add_concurrent_index :cluster_agent_tokens, :agent_id, name: OLD_INDEX
    remove_concurrent_index_by_name :cluster_agent_tokens, NEW_INDEX
  end
end