summaryrefslogtreecommitdiff
path: root/db/post_migrate/20220601152916_add_user_id_and_ip_address_success_index_to_authentication_events.rb
blob: aa860959c20795ed610928f2e00eff9f76ef7f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class AddUserIdAndIpAddressSuccessIndexToAuthenticationEvents < Gitlab::Database::Migration[2.0]
  OLD_INDEX_NAME = 'index_authentication_events_on_user_id'
  NEW_INDEX_NAME = 'index_authentication_events_on_user_and_ip_address_and_result'

  disable_ddl_transaction!

  def up
    add_concurrent_index :authentication_events, [:user_id, :ip_address, :result], name: NEW_INDEX_NAME
    remove_concurrent_index_by_name :authentication_events, OLD_INDEX_NAME
  end

  def down
    add_concurrent_index :authentication_events, :user_id, name: OLD_INDEX_NAME
    remove_concurrent_index_by_name :authentication_events, NEW_INDEX_NAME
  end
end