BigW Consortium Gitlab

20161020180657_add_minimum_key_length_to_application_settings.rb 1.18 KB
Newer Older
1 2 3 4 5 6 7 8 9
class AddMinimumKeyLengthToApplicationSettings < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  disable_ddl_transaction!

  def up
Nick Thomas committed
10
    # A key restriction has these possible states:
11 12
    #
    #   * -1 means "this key type is completely disabled"
Nick Thomas committed
13 14
    #   * 0 means "all keys of this type are valid"
    #   * > 0 means "keys must have at least this many bits to be valid"
15
    #
Nick Thomas committed
16
    # The default is 0, for backward compatibility
17 18 19 20
    add_column_with_default :application_settings, :rsa_key_restriction, :integer, default: 0
    add_column_with_default :application_settings, :dsa_key_restriction, :integer, default: 0
    add_column_with_default :application_settings, :ecdsa_key_restriction, :integer, default: 0
    add_column_with_default :application_settings, :ed25519_key_restriction, :integer, default: 0
21 22 23
  end

  def down
24 25 26 27
    remove_column :application_settings, :rsa_key_restriction
    remove_column :application_settings, :dsa_key_restriction
    remove_column :application_settings, :ecdsa_key_restriction
    remove_column :application_settings, :ed25519_key_restriction
28 29
  end
end