debian-mirror-gitlab/db/migrate/20220630202329_add_partial_index_on_oauth_access_tokens_revoked_at_with_order.rb
2022-08-13 15:12:31 +05:30

21 lines
915 B
Ruby

# frozen_string_literal: true
class AddPartialIndexOnOauthAccessTokensRevokedAtWithOrder < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
INDEX_NAME = 'partial_index_user_id_app_id_created_at_token_not_revoked'
EXISTING_INDEX_NAME = 'partial_index_resource_owner_id_created_at_token_not_revoked'
def up
add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :application_id, :created_at],
name: INDEX_NAME, where: 'revoked_at IS NULL'
remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at], name: EXISTING_INDEX_NAME
end
def down
add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at],
name: EXISTING_INDEX_NAME, where: 'revoked_at IS NULL'
remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :application_id, :created_at], name: INDEX_NAME
end
end