Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20200508091106_remove_bot_type.rb « post_migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2afcf5308e7687d15b444a8331d99f46c0595405 (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
28
29
# frozen_string_literal: true

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

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    remove_concurrent_index_by_name :users, 'index_users_on_bot_type'

    with_lock_retries do
      remove_column :users, :bot_type
    end
  end

  def down
    unless column_exists?(:users, :bot_type)
      with_lock_retries do
        add_column :users, :bot_type, :integer, limit: 2 # rubocop:disable Migration/AddColumnsToWideTables
      end
    end

    execute 'UPDATE users set bot_type = user_type WHERE user_type IN(1,2,3,6)'

    add_concurrent_index :users, :bot_type
  end
end