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

class AddForbiddenStateIndexToUsers < Gitlab::Database::Migration[1.0]
  disable_ddl_transaction!

  INDEX_NAME = 'users_forbidden_state_idx'

  def up
    add_concurrent_index :users, :id,
      name: INDEX_NAME,
      where: "confirmed_at IS NOT NULL AND (state <> ALL (ARRAY['blocked', 'banned', 'ldap_blocked']))"
  end

  def down
    remove_concurrent_index_by_name :users, INDEX_NAME
  end
end