CREATE TABLE IF NOT EXISTS xbp_docker_logs (
    docker_log_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
    project_id uuid REFERENCES xbp_projects(project_id) ON DELETE SET NULL,
    container_id text,
    command text,
    stream text,
    message text,
    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_docker_logs_project_id ON xbp_docker_logs (project_id);
CREATE INDEX IF NOT EXISTS idx_xbp_docker_logs_container_id ON xbp_docker_logs (container_id);
CREATE INDEX IF NOT EXISTS idx_xbp_docker_logs_occurred_at ON xbp_docker_logs (occurred_at DESC);
