summaryrefslogtreecommitdiff
path: root/db/post_migrate/20190511144331_remove_users_support_type.rb
blob: e72fbb229b893234c7e48f33e9ed3dba4b216993 (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
27
# frozen_string_literal: true

class RemoveUsersSupportType < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  INDEX_STATE_INTERNAL_ATTRS = 'index_users_on_state_and_internal_attrs'

  disable_ddl_transaction!

  def up
    remove_concurrent_index :users, :state, name: INDEX_STATE_INTERNAL_ATTRS
    remove_concurrent_index :users, :support_bot

    remove_column :users, :support_bot
  end

  def down
    add_column :users, :support_bot, :boolean # rubocop:disable Migration/AddColumnsToWideTables

    add_concurrent_index :users, :support_bot
    add_concurrent_index :users, :state,
      name: INDEX_STATE_INTERNAL_ATTRS,
      where: 'ghost <> true AND support_bot <> true'
  end
end