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