feat: implement get session by user
This commit is contained in:
4
db/sqlc/migrations/000001_init_schema.down.sql
Normal file
4
db/sqlc/migrations/000001_init_schema.down.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
DROP TABLE IF EXISTS public.verification;
|
||||
DROP TABLE IF EXISTS public.session;
|
||||
DROP TABLE IF EXISTS public.account;
|
||||
DROP TABLE IF EXISTS public."user";
|
||||
52
db/sqlc/migrations/000001_init_schema.up.sql
Normal file
52
db/sqlc/migrations/000001_init_schema.up.sql
Normal 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)
|
||||
);
|
||||
@@ -1,5 +0,0 @@
|
||||
DROP INDEX IF EXISTS idx_identifiers_created_at;
|
||||
DROP INDEX IF EXISTS idx_identifiers_slug;
|
||||
|
||||
DROP TABLE IF EXISTS identifiers;
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
CREATE TABLE identifiers (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
slug VARCHAR(255) UNIQUE NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX idx_identifiers_created_at
|
||||
ON identifiers(created_at);
|
||||
|
||||
CREATE INDEX idx_identifiers_slug
|
||||
ON identifiers(slug);
|
||||
Reference in New Issue
Block a user