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

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

class UpdateMinimumPasswordLength < ActiveRecord::Migration[5.2]
  DOWNTIME = false

  def up
    value_to_be_updated_to = [
      Devise.password_length.min,
      ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH
    ].max

    execute "UPDATE application_settings SET minimum_password_length = #{value_to_be_updated_to}"

    ApplicationSetting.expire
  end

  def down
    value_to_be_updated_to = ApplicationSetting::DEFAULT_MINIMUM_PASSWORD_LENGTH

    execute "UPDATE application_settings SET minimum_password_length = #{value_to_be_updated_to}"

    ApplicationSetting.expire
  end
end