diff --git a/README.md b/README.md index 41a010ce..9c631802 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ devise :database_authenticatable, :registerable, :recoverable, :rememberable, Then create your migration file using the Rails generator, such as: ``` -rails g migration AddTwoFactorFieldsToUsers second_factor_attempts_count:integer encrypted_otp_secret_key:string:index encrypted_otp_secret_key_iv:string encrypted_otp_secret_key_salt:string direct_otp:string direct_otp_sent_at:datetime totp_timestamp:timestamp +rails g migration AddTwoFactorFieldsToUsers second_factor_attempts_count:integer encrypted_otp_secret_key:string:index encrypted_otp_secret_key_iv:string encrypted_otp_secret_key_salt:string direct_otp:string direct_otp_sent_at:datetime totp_timestamp:integer ``` Open your migration file (it will be in the `db/migrate` directory and will be @@ -174,7 +174,7 @@ The following database fields are new in version 2. To add them, generate a migration such as: - $ rails g migration AddTwoFactorFieldsToUsers direct_otp:string direct_otp_sent_at:datetime totp_timestamp:timestamp + $ rails g migration AddTwoFactorFieldsToUsers direct_otp:string direct_otp_sent_at:datetime totp_timestamp:integer The `otp_secret_key` is only required for users who use TOTP (Google Authenticator) codes, so unless it has been shared with the user it should be set to `nil`. The diff --git a/lib/generators/active_record/templates/migration.rb b/lib/generators/active_record/templates/migration.rb index 251ef402..9eaa4714 100644 --- a/lib/generators/active_record/templates/migration.rb +++ b/lib/generators/active_record/templates/migration.rb @@ -6,7 +6,7 @@ def change add_column :<%= table_name %>, :encrypted_otp_secret_key_salt, :string add_column :<%= table_name %>, :direct_otp, :string add_column :<%= table_name %>, :direct_otp_sent_at, :datetime - add_column :<%= table_name %>, :totp_timestamp, :timestamp + add_column :<%= table_name %>, :totp_timestamp, :integer add_index :<%= table_name %>, :encrypted_otp_secret_key, unique: true end diff --git a/lib/two_factor_authentication/schema.rb b/lib/two_factor_authentication/schema.rb index 9f938b7c..98f66983 100644 --- a/lib/two_factor_authentication/schema.rb +++ b/lib/two_factor_authentication/schema.rb @@ -25,7 +25,7 @@ def direct_otp_sent_at end def totp_timestamp - apply_devise_schema :totp_timestamp, Timestamp + apply_devise_schema :totp_timestamp, Integer end end end