Set null kdf_iterations to 5000, which is what the old default used to be. As the default changes in the future (or as it did in 5ccd4174b), this should still be 5000.
···11class NoNullKdfIterations < ActiveRecord::Migration[5.1]
22 def change
33 User.all.each do |u|
44+ # any old users without a kdf_iterations value probably have the old
55+ # value of 5000
46 if !u.kdf_iterations
55- u.kdf_iterations = Bitwarden::KDF::DEFAULT_ITERATIONS[User::DEFAULT_KDF_TYPE]
66- end
77- if !u.kdf_type
88- u.kdf_type = User::DEFAULT_KDF_TYPE
77+ u.kdf_iterations = 5000
88+ u.kdf_type = Bitwarden::KDF::PBKDF2
99 end
1010 u.save!
1111 end
12121313+ # but going forward, any new users should get whatever defaults are set in
1414+ # the future
1315 change_column :users, :kdf_iterations, :integer, :null => false,
1416 :default => Bitwarden::KDF::DEFAULT_ITERATIONS[User::DEFAULT_KDF_TYPE]
1517 end