Sha256: d89229e83b15b8e26a19d3ac420274cd636b40888bb943bd55854dd7b4e6ffcd

Contents?: true

Size: 386 Bytes

Versions: 5

Compression:

Stored size: 386 Bytes

Contents

class PopulateOtpColumn < ActiveRecord::Migration
  def up
    User.reset_column_information

    User.find_each do |user|
      user.otp_secret_key = user.read_attribute('otp_secret_key')
      user.save!
    end
  end

  def down
    User.reset_column_information

    User.find_each do |user|
      user.otp_secret_key = ROTP::Base32.random_base32
      user.save!
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
two_factor_authentication-2.1.1 spec/rails_app/db/migrate/20151224180310_populate_otp_column.rb
two_factor_authentication-2.1.0 spec/rails_app/db/migrate/20151224180310_populate_otp_column.rb
two_factor_authentication-2.0.1 spec/rails_app/db/migrate/20151224180310_populate_otp_column.rb
two_factor_authentication-2.0.0 spec/rails_app/db/migrate/20151224180310_populate_otp_column.rb
two_factor_authentication-1.1.5 spec/rails_app/db/migrate/20151224180310_populate_otp_column.rb