debian-mirror-gitlab/db/post_migrate/20220404183350_add_forbidden_state_index_to_users.rb
2022-06-21 17:19:12 +05:30

18 lines
432 B
Ruby

# 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