CREATE TABLE IF NOT EXISTS xbp_logs (
    log_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
    log_level text NOT NULL,
    command text NOT NULL,
    message text NOT NULL,
    details text,
    duration_ms bigint,
    occurred_at timestamptz NOT NULL,
    metadata jsonb NOT NULL DEFAULT '{}'::jsonb,
    created_at timestamptz NOT NULL DEFAULT now(),
    updated_at timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX IF NOT EXISTS idx_xbp_logs_command ON xbp_logs (command);
CREATE INDEX IF NOT EXISTS idx_xbp_logs_occurred_at ON xbp_logs (occurred_at DESC);
