summaryrefslogtreecommitdiff
path: root/db/migrate/20200518091745_add_index_to_personal_access_token_impersonation.rb
blob: f9681f1a9762c47d6acd15d34fb6dcbf00963e03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class AddIndexToPersonalAccessTokenImpersonation < ActiveRecord::Migration[6.0]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false
  INDEX_NAME = 'index_expired_and_not_notified_personal_access_tokens'

  disable_ddl_transaction!

  def up
    add_concurrent_index(
      :personal_access_tokens,
      [:id, :expires_at],
      where: "impersonation = FALSE AND revoked = FALSE AND expire_notification_delivered = FALSE",
      name: INDEX_NAME
    )
  end

  def down
    remove_concurrent_index_by_name(
      :personal_access_tokens,
      name: INDEX_NAME
    )
  end
end