mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 01:51:37 -04:00
36 lines
1.2 KiB
SQL
36 lines
1.2 KiB
SQL
CREATE TABLE IF NOT EXISTS users
|
|
(
|
|
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
|
|
data JSONB NOT NULL,
|
|
id TEXT DEFAULT random_alphanumeric(12) NOT NULL,
|
|
name TEXT NOT NULL,
|
|
name_username_vector tsvector GENERATED ALWAYS AS (
|
|
to_tsvector(
|
|
'english'::regconfig,
|
|
(name || ' '::text) || username
|
|
)
|
|
) STORED,
|
|
username TEXT NOT NULL,
|
|
avatar_url TEXT,
|
|
is_banned_from_posting BOOLEAN DEFAULT FALSE NOT NULL,
|
|
|
|
CONSTRAINT users_pkey PRIMARY KEY (id)
|
|
);
|
|
|
|
-- Row Level Security
|
|
ALTER TABLE users
|
|
ENABLE ROW LEVEL SECURITY;
|
|
|
|
-- Policies
|
|
DROP POLICY IF EXISTS "public read" ON users;
|
|
CREATE POLICY "public read" ON users
|
|
FOR SELECT
|
|
USING (true);
|
|
|
|
-- Indexes
|
|
CREATE INDEX IF NOT EXISTS user_username_idx ON public.users USING btree (username);
|
|
|
|
CREATE INDEX IF NOT EXISTS users_created_time ON public.users USING btree (created_time DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS users_name_idx ON public.users USING btree (name);
|