summaryrefslogtreecommitdiff
path: root/db/post_migrate/20191205084057_update_minimum_password_length.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20191205084057_update_minimum_password_length.rb')
-rw-r--r--db/post_migrate/20191205084057_update_minimum_password_length.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/db/post_migrate/20191205084057_update_minimum_password_length.rb b/db/post_migrate/20191205084057_update_minimum_password_length.rb
new file mode 100644
index 00000000000..d9324347075
--- /dev/null
+++ b/db/post_migrate/20191205084057_update_minimum_password_length.rb
@@ -0,0 +1,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