summaryrefslogtreecommitdiff
path: root/db/migrate/20170124193147_add_two_factor_columns_to_namespaces.rb
blob: ae37da275fd60f4bc03f39e3a218528b5ead34b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# rubocop:disable Migration/AddColumnWithDefaultToLargeTable
class AddTwoFactorColumnsToNamespaces < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_column_with_default(:namespaces, :require_two_factor_authentication, :boolean, default: false)
    add_column_with_default(:namespaces, :two_factor_grace_period, :integer, default: 48)

    add_concurrent_index(:namespaces, :require_two_factor_authentication)
  end

  def down
    remove_column(:namespaces, :require_two_factor_authentication)
    remove_column(:namespaces, :two_factor_grace_period)

    remove_concurrent_index(:namespaces, :require_two_factor_authentication) if index_exists?(:namespaces, :require_two_factor_authentication)
  end
end