feat: initial commit

Axum/Postgres server with auth, migrations, and Docker setup.
This commit is contained in:
2026-08-13 13:08:13 +02:00
commit 9617f4415c
33 changed files with 3974 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
username TEXT NOT NULL UNIQUE,
display_name TEXT NOT NULL,
avatar_url TEXT,
bio TEXT,
email_verified BOOLEAN NOT NULL DEFAULT false,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMPTZ
);
CREATE TYPE auth_token_kind AS ENUM ('password_reset', 'email_verification', 'refresh_token');
CREATE TABLE auth_tokens (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
token_hash TEXT NOT NULL,
kind auth_token_kind NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
used_at TIMESTAMPTZ,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX auth_tokens_user_id_idx ON auth_tokens(user_id);
CREATE INDEX auth_tokens_token_hash_idx ON auth_tokens(token_hash);