-- AlterTable
ALTER TABLE "optimization_events" ADD COLUMN     "baseBranch" TEXT,
ADD COLUMN     "file_path" TEXT,
ADD COLUMN     "function_name" TEXT,
ADD COLUMN     "is_staging" BOOLEAN DEFAULT false,
ADD COLUMN     "speedup_pct" DOUBLE PRECISION,
ADD COLUMN     "speedup_x" DOUBLE PRECISION,
ADD COLUMN     "status" TEXT;

-- CreateTable
CREATE TABLE "comments" (
    "id" TEXT NOT NULL,
    "optimization_event_id" TEXT NOT NULL,
    "content" TEXT NOT NULL,
    "created_at" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "author_user_id" TEXT,

    CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "comments_optimization_event_id_idx" ON "comments"("optimization_event_id");

-- CreateIndex
CREATE INDEX "comments_author_user_id_idx" ON "comments"("author_user_id");

-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_optimization_event_id_fkey" FOREIGN KEY ("optimization_event_id") REFERENCES "optimization_events"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_author_user_id_fkey" FOREIGN KEY ("author_user_id") REFERENCES "users"("user_id") ON DELETE SET NULL ON UPDATE CASCADE;
