summaryrefslogtreecommitdiff
path: root/db/migrate/20200317110602_add_migrating_user_highest_roles_table_index_to_users.rb
blob: e67dc323c3940d855608ed88997eb53440dc48e3 (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
# frozen_string_literal: true

# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

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

  DOWNTIME = false
  INDEX_NAME = 'index_for_migrating_user_highest_roles_table'

  disable_ddl_transaction!

  def up
    add_concurrent_index :users,
                         :id,
                         where: "state = 'active' AND user_type IS NULL AND bot_type IS NULL AND ghost IS NOT TRUE",
                         name: INDEX_NAME
  end

  def down
    remove_concurrent_index :users, :id, name: INDEX_NAME
  end
end