20 lines
641 B
Elixir
20 lines
641 B
Elixir
defmodule Towerops.Repo.Migrations.CreateUserTotpDevices do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:user_totp_devices, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
add :user_id, references(:users, type: :binary_id, on_delete: :delete_all), null: false
|
|
|
|
add :name, :string, null: false
|
|
add :totp_secret, :binary, null: false
|
|
add :last_used_at, :utc_datetime
|
|
add :created_at, :utc_datetime, null: false
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create index(:user_totp_devices, [:user_id])
|
|
create index(:user_totp_devices, [:user_id, :last_used_at])
|
|
end
|
|
end
|