summaryrefslogtreecommitdiff
path: root/db/migrate/20190801142441_add_throttle_protected_path_columns.rb
blob: f9e0922ad66aa05848750e62b6979830c22d13cb (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 AddThrottleProtectedPathColumns < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  DEFAULT_PROTECTED_PATHS = [
    '/users/password',
    '/users/sign_in',
    '/api/v3/session.json',
    '/api/v3/session',
    '/api/v4/session.json',
    '/api/v4/session',
    '/users',
    '/users/confirmation',
    '/unsubscribes/',
    '/import/github/personal_access_token'
  ]

  # rubocop:disable Migration/PreventStrings
  def change
    add_column :application_settings, :throttle_protected_paths_enabled, :boolean, default: true, null: false
    add_column :application_settings, :throttle_protected_paths_requests_per_period, :integer, default: 10, null: false
    add_column :application_settings, :throttle_protected_paths_period_in_seconds, :integer, default: 60, null: false
    add_column :application_settings, :protected_paths, :string, array: true, limit: 255, default: DEFAULT_PROTECTED_PATHS
  end
  # rubocop:enable Migration/PreventStrings
end