42 lines
1.4 KiB
Elixir
42 lines
1.4 KiB
Elixir
defmodule Mv.Repo.Migrations.AddJoinRequests do
|
|
@moduledoc """
|
|
Adds join_requests table for public join flow (onboarding concept §2.3.2).
|
|
"""
|
|
use Ecto.Migration
|
|
|
|
def up do
|
|
create table(:join_requests, primary_key: false) do
|
|
add :id, :uuid, null: false, default: fragment("uuid_generate_v7()"), primary_key: true
|
|
add :email, :string, null: false
|
|
add :confirmation_token_hash, :string, null: false
|
|
add :status, :string, null: false
|
|
add :submitted_at, :utc_datetime_usec, null: false
|
|
add :source, :string, null: false
|
|
add :schema_version, :bigint, null: false
|
|
add :payload, :map, null: true
|
|
add :approved_at, :utc_datetime_usec, null: true
|
|
add :rejected_at, :utc_datetime_usec, null: true
|
|
add :reviewed_by_user_id, :uuid, null: true
|
|
|
|
add :inserted_at, :utc_datetime_usec,
|
|
null: false,
|
|
default: fragment("(now() AT TIME ZONE 'utc')")
|
|
|
|
add :updated_at, :utc_datetime_usec,
|
|
null: false,
|
|
default: fragment("(now() AT TIME ZONE 'utc')")
|
|
end
|
|
|
|
create unique_index(:join_requests, [:confirmation_token_hash],
|
|
name: "join_requests_unique_confirmation_token_hash_index"
|
|
)
|
|
end
|
|
|
|
def down do
|
|
drop_if_exists unique_index(:join_requests, [:confirmation_token_hash],
|
|
name: "join_requests_unique_confirmation_token_hash_index"
|
|
)
|
|
|
|
drop table(:join_requests)
|
|
end
|
|
end
|