Files
tunnel-please-controller/db/sqlc/migrations/000001_init_schema.up.sql
2026-01-03 19:06:35 +07:00

52 lines
1.7 KiB
SQL

CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS public."user" (
id text NOT NULL,
ssh_identifier text UNIQUE NOT NULL DEFAULT substr(encode(gen_random_bytes(16), 'hex'), 1, 32),
name text NOT NULL,
email text NOT NULL,
email_verified boolean DEFAULT false NOT NULL,
image text,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone DEFAULT now() NOT NULL,
CONSTRAINT user_pkey PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.account (
id text NOT NULL,
account_id text NOT NULL,
provider_id text NOT NULL,
user_id text NOT NULL,
access_token text,
refresh_token text,
id_token text,
access_token_expires_at timestamp without time zone,
refresh_token_expires_at timestamp without time zone,
scope text,
password text,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone NOT NULL,
CONSTRAINT account_pkey PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.session (
id text NOT NULL,
expires_at timestamp without time zone NOT NULL,
token text NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone NOT NULL,
ip_address text,
user_agent text,
user_id text NOT NULL,
CONSTRAINT session_pkey PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS public.verification (
id text NOT NULL,
identifier text NOT NULL,
value text NOT NULL,
expires_at timestamp without time zone NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone DEFAULT now() NOT NULL,
CONSTRAINT verification_pkey PRIMARY KEY (id)
);