Sha256: 96d0408c251137e35a743e11ecc1a2972deaa9bf6f7bae4b11a60efd9093ab2e

Contents?: true

Size: 606 Bytes

Versions: 1

Compression:

Stored size: 606 Bytes

Contents

# frozen_string_literal: true

class Add2faFields < ActiveRecord::Migration[7.0]
  def change
    change_table :users do |t|
      t.boolean :otp_enabled, null: false, default: false
      t.string :otp_secret
      t.datetime :last_otp_at
      t.jsonb :hashed_recovery_codes, null: false, default: []
      t.string :session_token
    end

    rename_column :users, :hashed_password, :password_digest

    reversible do |dir|
      dir.up do
        User.find_each { |u| u.update(session_token: SecureRandom.hex(32)) }
        change_column_null :users, :session_token, false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.14.0 db/migrate/20240126160700_add_2fa_fields.rb