UPDATE: database

This commit is contained in:
2026-03-24 00:00:44 +07:00
parent 3626c12319
commit eedd300861
18 changed files with 237 additions and 124 deletions

View File

@@ -0,0 +1,29 @@
CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE TABLE IF NOT EXISTS user_profiles (
user_id UUID PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
display_name TEXT,
full_name TEXT,
avatar_url TEXT,
bio TEXT,
location TEXT,
website TEXT,
country_code CHAR(2),
phone TEXT,
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX idx_user_profiles_display_name
ON user_profiles USING gin (display_name gin_trgm_ops);
CREATE INDEX idx_user_profiles_country
ON user_profiles(country_code);
CREATE UNIQUE INDEX idx_user_profiles_phone
ON user_profiles(phone);
CREATE TRIGGER trigger_user_profiles_updated_at
BEFORE UPDATE ON user_profiles
FOR EACH ROW
EXECUTE FUNCTION update_updated_at();