22 lines
626 B
Ruby
22 lines
626 B
Ruby
class CreateOtpCodes < ActiveRecord::Migration[8.0]
|
|
def change
|
|
create_table :otp_codes do |t|
|
|
t.string :phone_number, null: false
|
|
t.string :code, null: false
|
|
t.string :purpose, default: "authentication"
|
|
t.datetime :expires_at, null: false
|
|
t.boolean :verified, default: false
|
|
t.datetime :verified_at
|
|
t.integer :attempts, default: 0
|
|
t.string :ip_address
|
|
t.jsonb :metadata, default: {}
|
|
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :otp_codes, :phone_number
|
|
add_index :otp_codes, :expires_at
|
|
add_index :otp_codes, [:phone_number, :verified, :expires_at]
|
|
end
|
|
end
|