feat: add join request resource
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2a04fad4fe
commit
2515a679b8
9 changed files with 323 additions and 5 deletions
53
priv/repo/migrations/20260309141437_add_join_requests.exs
Normal file
53
priv/repo/migrations/20260309141437_add_join_requests.exs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
defmodule Mv.Repo.Migrations.AddJoinRequests do
|
||||
@moduledoc """
|
||||
Creates join_requests table for the public join flow (onboarding, double opt-in).
|
||||
|
||||
Stores join form submissions with status pending_confirmation → submitted (after email confirm).
|
||||
Token stored as hash only; 24h retention for unconfirmed records (cleanup via scheduled job).
|
||||
"""
|
||||
|
||||
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 :status, :text, null: false, default: "pending_confirmation"
|
||||
add :email, :text, null: false
|
||||
add :first_name, :text
|
||||
add :last_name, :text
|
||||
add :form_data, :map
|
||||
add :schema_version, :integer
|
||||
|
||||
add :confirmation_token_hash, :text
|
||||
add :confirmation_token_expires_at, :utc_datetime_usec
|
||||
add :confirmation_sent_at, :utc_datetime_usec
|
||||
|
||||
add :submitted_at, :utc_datetime_usec
|
||||
add :approved_at, :utc_datetime_usec
|
||||
add :rejected_at, :utc_datetime_usec
|
||||
add :reviewed_by_user_id, :uuid
|
||||
add :source, :text
|
||||
|
||||
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_confirmation_token_hash_unique",
|
||||
where: "confirmation_token_hash IS NOT NULL"
|
||||
)
|
||||
|
||||
create index(:join_requests, [:email])
|
||||
create index(:join_requests, [:status])
|
||||
end
|
||||
|
||||
def down do
|
||||
drop table(:join_requests)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue