CREATE TABLE users (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    name VARCHAR(255) NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    password_hash VARCHAR(255),
    phone VARCHAR(50) DEFAULT '',
    avatar VARCHAR(500) DEFAULT '',
    address TEXT DEFAULT '',
    role VARCHAR(20) NOT NULL DEFAULT 'user' CHECK (role IN ('user', 'worker')),
    google_id VARCHAR(255) UNIQUE,
    is_verified BOOLEAN NOT NULL DEFAULT false,
    push_token VARCHAR(500),
    expo_push_token VARCHAR(500),
    dark_mode BOOLEAN NOT NULL DEFAULT false,
    location GEOGRAPHY(Point, 4326),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_users_email ON users (email);
CREATE INDEX idx_users_google_id ON users (google_id);
CREATE INDEX idx_users_location ON users USING GIST (location);
