blob: 2222698dcea31fdc142d72cd6502c71da9dd62b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# frozen_string_literal: true
class AddPartialIndexOnOauthAccessTokensRevokedAt < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
INDEX_NAME = 'partial_index_resource_owner_id_created_at_token_not_revoked'
EXISTING_INDEX_NAME = 'index_oauth_access_tokens_on_resource_owner_id'
def up
add_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at],
name: INDEX_NAME, where: 'revoked_at IS NULL'
remove_concurrent_index :oauth_access_tokens, :resource_owner_id, name: EXISTING_INDEX_NAME
end
def down
add_concurrent_index :oauth_access_tokens, :resource_owner_id, name: EXISTING_INDEX_NAME
remove_concurrent_index :oauth_access_tokens, [:resource_owner_id, :created_at], name: INDEX_NAME
end
end
|