Add OAuth backend scaffold

This commit is contained in:
MrDiderot
2026-07-22 22:54:03 +02:00
parent 77d93c4f8d
commit 39a0e35fd2
14 changed files with 2971 additions and 37 deletions

33
backend/schema.sql Normal file
View File

@@ -0,0 +1,33 @@
create extension if not exists pgcrypto;
create table if not exists users (
id uuid primary key default gen_random_uuid(),
email text unique,
display_name text not null default '',
avatar_url text,
password_hash text,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now()
);
create table if not exists identities (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references users(id) on delete cascade,
provider text not null check (provider in ('apple', 'google', 'email')),
provider_subject text not null,
email text,
created_at timestamptz not null default now(),
unique(provider, provider_subject)
);
create table if not exists premium_entitlements (
user_id uuid primary key references users(id) on delete cascade,
source text not null default 'app_store',
product_id text not null,
active boolean not null default false,
expires_at timestamptz,
updated_at timestamptz not null default now()
);
create index if not exists identities_user_id_idx on identities(user_id);
create index if not exists premium_entitlements_active_idx on premium_entitlements(active);