tarakan/priv/repo/migrations/20260710050234_create_accounts_auth_tables.exs
Maxfield Luke af6077b9c3
All checks were successful
CI and deploy / Test (push) Successful in 4m52s
CI and deploy / Deploy production (push) Successful in 23s
Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at
https://git.elektrine.com/elektrine/tarakan.
2026-07-29 04:43:40 -04:00

34 lines
1 KiB
Elixir

defmodule Tarakan.Repo.Migrations.CreateAccountsAuthTables do
use Ecto.Migration
def change do
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
create table(:accounts) do
add :handle, :citext, null: false
add :display_name, :string
add :email, :citext
add :hashed_password, :string
add :confirmed_at, :utc_datetime
add :reputation, :bigint, null: false, default: 0
timestamps(type: :utc_datetime)
end
create unique_index(:accounts, [:handle])
create unique_index(:accounts, [:email], where: "email IS NOT NULL")
create table(:accounts_tokens) do
add :account_id, references(:accounts, on_delete: :delete_all), null: false
add :token, :binary, null: false
add :context, :string, null: false
add :sent_to, :string
add :authenticated_at, :utc_datetime
timestamps(type: :utc_datetime, updated_at: false)
end
create index(:accounts_tokens, [:account_id])
create unique_index(:accounts_tokens, [:context, :token])
end
end