-- CreateTable
CREATE TABLE "refinements_events" (
    "trace_id" TEXT NOT NULL,
    "user_id" TEXT NOT NULL,
    "repo_func_key" TEXT NOT NULL,
    "candidates" JSONB NOT NULL DEFAULT '[]',

    CONSTRAINT "refinements_events_pkey" PRIMARY KEY ("trace_id")
);

-- CreateIndex
CREATE INDEX "refinements_events_repo_func_key_idx" ON "refinements_events"("repo_func_key");

-- AddForeignKey
ALTER TABLE "refinements_events" ADD CONSTRAINT "refinements_events_trace_id_fkey" FOREIGN KEY ("trace_id") REFERENCES "optimization_features"("trace_id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "refinements_events" ADD CONSTRAINT "refinements_events_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("user_id") ON DELETE RESTRICT ON UPDATE CASCADE;
