feat: implement get session by user

This commit is contained in:
2026-01-02 23:00:13 +07:00
parent f7a1044343
commit d864027c31
8 changed files with 277 additions and 198 deletions

View File

@@ -0,0 +1,52 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS public."user" (
id text NOT NULL,
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)
);