ensl.org/db/migrate/20200401031518_update_passwords_to_scrypt.rb

19 lines
440 B
Ruby
Raw Normal View History

2020-04-02 00:15:28 +00:00
ENV['SCRYPT_MAX_TIME'] ||= "0.03"
2020-04-02 00:08:19 +00:00
class UpdatePasswordsToScrypt < ActiveRecord::Migration[6.0]
require 'scrypt'
def up
2020-04-02 02:08:58 +00:00
SCrypt::Engine.calibrate!(max_time: ENV['SCRYPT_MAX_TIME'].to_f)
2020-04-02 00:08:19 +00:00
ActiveRecord::Base.transaction do
User.all.order(:id).each do |user|
2020-04-02 00:15:28 +00:00
user.team = nil unless user&.team&.present?
if user.valid?
user.update_password
user.save!
end
2020-04-02 00:08:19 +00:00
end
end
end
end