-- 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;
