- PUT /api/v1/me (update name, city, bio, gender, photo) - GET/PUT /api/v1/me/prefs (drinks, activities, purposes, language) - PUT /api/v1/me/location (auto-noise ~300m) - PUT /api/v1/me/visibility (hide/show on map) - GET /api/v1/search/nearby?lat&lng&radius (haversine, 1h TTL) - GET /api/v1/users/:id (public profile, no email/phone) - migrations 0002: user_preferences, user_locations
23 lines
886 B
SQL
23 lines
886 B
SQL
-- User preferences: что пьёт, что делает, цели
|
|
CREATE TABLE IF NOT EXISTS user_preferences (
|
|
user_id UUID PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
|
drinks TEXT[] NOT NULL DEFAULT '{}',
|
|
activities TEXT[] NOT NULL DEFAULT '{}',
|
|
purposes TEXT[] NOT NULL DEFAULT '{}',
|
|
language TEXT DEFAULT 'ru',
|
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
-- User location (приблизительная, обновляется)
|
|
CREATE TABLE IF NOT EXISTS user_locations (
|
|
user_id UUID PRIMARY KEY REFERENCES users(id) ON DELETE CASCADE,
|
|
lat DOUBLE PRECISION,
|
|
lng DOUBLE PRECISION,
|
|
visible BOOLEAN NOT NULL DEFAULT TRUE,
|
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_user_locations_visible
|
|
ON user_locations(visible, updated_at DESC)
|
|
WHERE visible = TRUE;
|