summaryrefslogtreecommitdiff
path: root/db/migrate/20171006220837_add_global_rate_limits_to_application_settings.rb
blob: 55e822752af7f01c8bb0797122d06df58bf1ffb8 (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
30
31
32
33
34
35
36
37
38
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class AddGlobalRateLimitsToApplicationSettings < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  disable_ddl_transaction!

  def up
    add_column_with_default :application_settings, :throttle_unauthenticated_enabled, :boolean, default: false, allow_null: false
    add_column_with_default :application_settings, :throttle_unauthenticated_requests_per_period, :integer, default: 3600, allow_null: false
    add_column_with_default :application_settings, :throttle_unauthenticated_period_in_seconds, :integer, default: 3600, allow_null: false

    add_column_with_default :application_settings, :throttle_authenticated_api_enabled, :boolean, default: false, allow_null: false
    add_column_with_default :application_settings, :throttle_authenticated_api_requests_per_period, :integer, default: 7200, allow_null: false
    add_column_with_default :application_settings, :throttle_authenticated_api_period_in_seconds, :integer, default: 3600, allow_null: false

    add_column_with_default :application_settings, :throttle_authenticated_web_enabled, :boolean, default: false, allow_null: false
    add_column_with_default :application_settings, :throttle_authenticated_web_requests_per_period, :integer, default: 7200, allow_null: false
    add_column_with_default :application_settings, :throttle_authenticated_web_period_in_seconds, :integer, default: 3600, allow_null: false
  end

  def down
    remove_column :application_settings, :throttle_authenticated_web_period_in_seconds
    remove_column :application_settings, :throttle_authenticated_web_requests_per_period
    remove_column :application_settings, :throttle_authenticated_web_enabled

    remove_column :application_settings, :throttle_authenticated_api_period_in_seconds
    remove_column :application_settings, :throttle_authenticated_api_requests_per_period
    remove_column :application_settings, :throttle_authenticated_api_enabled

    remove_column :application_settings, :throttle_unauthenticated_period_in_seconds
    remove_column :application_settings, :throttle_unauthenticated_requests_per_period
    remove_column :application_settings, :throttle_unauthenticated_enabled
  end
end