ensl.org/db/migrate/20200401031518_update_passwords_to_scrypt.rb
2020-04-02 05:08:58 +03:00

18 lines
440 B
Ruby

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