🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(comments): update comment reaction table with project id (#10082)
Michael Fröhlich5ab1b784ae85
diff --git a/packages/shared/prisma/generated/types.ts b/packages/shared/prisma/generated/types.tsindex 264ae4cfdd..a0cd0d1810 100644--- a/packages/shared/prisma/generated/types.ts+++ b/packages/shared/prisma/generated/types.ts@@ -364,6 +364,7 @@ export type Comment = {};export type CommentReaction = {id: string;+ project_id: string;comment_id: string;user_id: string;emoji: string;diff --git a/packages/shared/prisma/migrations/20251022143653_add_notification_preferences/migration.sql b/packages/shared/prisma/migrations/20251028143653_add_notification_preferences/migration.sqlsimilarity index 100%rename from packages/shared/prisma/migrations/20251022143653_add_notification_preferences/migration.sqlrename to packages/shared/prisma/migrations/20251028143653_add_notification_preferences/migration.sqldiff --git a/packages/shared/prisma/migrations/20251022143654_add_notification_preferences_redundant_index/migration.sql b/packages/shared/prisma/migrations/20251028143654_add_notification_preferences_redundant_index/migration.sqlsimilarity index 100%rename from packages/shared/prisma/migrations/20251022143654_add_notification_preferences_redundant_index/migration.sqlrename to packages/shared/prisma/migrations/20251028143654_add_notification_preferences_redundant_index/migration.sqldiff --git a/packages/shared/prisma/migrations/20251023000042_add_comment_reactions/migration.sql b/packages/shared/prisma/migrations/20251029000042_add_comment_reactions/migration.sqlsimilarity index 74%rename from packages/shared/prisma/migrations/20251023000042_add_comment_reactions/migration.sqlrename to packages/shared/prisma/migrations/20251029000042_add_comment_reactions/migration.sqlindex 84729ee667..0fba1dd9e8 100644--- a/packages/shared/prisma/migrations/20251023000042_add_comment_reactions/migration.sql+++ b/packages/shared/prisma/migrations/20251029000042_add_comment_reactions/migration.sql@@ -1,6 +1,7 @@-- CreateTableCREATE TABLE "comment_reactions" ("id" TEXT NOT NULL,+ "project_id" TEXT NOT NULL,"comment_id" TEXT NOT NULL,"user_id" TEXT NOT NULL,"emoji" TEXT NOT NULL,@@ -9,6 +10,8 @@ CREATE TABLE "comment_reactions" (CONSTRAINT "comment_reactions_pkey" PRIMARY KEY ("id"));+-- AddForeignKey+ALTER TABLE "comment_reactions" ADD CONSTRAINT "comment_reactions_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;-- AddForeignKeyALTER TABLE "comment_reactions" ADD CONSTRAINT "comment_reactions_comment_id_fkey" FOREIGN KEY ("comment_id") REFERENCES "comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;-- AddForeignKeydiff --git a/packages/shared/prisma/migrations/20251023000045_add_comment_reaction_idx3/migration.sql b/packages/shared/prisma/migrations/20251029000045_add_comment_reaction_idx3/migration.sqlsimilarity index 100%rename from packages/shared/prisma/migrations/20251023000045_add_comment_reaction_idx3/migration.sqlrename to packages/shared/prisma/migrations/20251029000045_add_comment_reaction_idx3/migration.sqldiff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 70a776f37b..373617862f 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -154,6 +154,7 @@ model Project {scoreConfig ScoreConfig[]BatchExport BatchExport[]comment Comment[]+ commentReactions CommentReaction[]annotationQueue AnnotationQueue[]annotationQueueItem AnnotationQueueItem[]TraceMedia TraceMedia[]@@ -699,6 +700,8 @@ model Comment {model CommentReaction {id String @id @default(cuid())+ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)commentId String @map("comment_id")comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)userId String @map("user_id")diff --git a/web/src/server/api/routers/commentReactions.ts b/web/src/server/api/routers/commentReactions.tsindex 03c381e1a1..91f5248885 100644--- a/web/src/server/api/routers/commentReactions.ts+++ b/web/src/server/api/routers/commentReactions.ts@@ -52,6 +52,7 @@ export const commentReactionsRouter = createTRPCRouter({},},create: {+ projectId: input.projectId,commentId: input.commentId,userId: ctx.session.user.id,emoji: input.emoji,@@ -103,16 +104,23 @@ export const commentReactionsRouter = createTRPCRouter({});}- await ctx.prisma.commentReaction.delete({+ // Delete reaction with project safety check+ const deletedReaction = await ctx.prisma.commentReaction.deleteMany({where: {- commentId_userId_emoji: {- commentId: input.commentId,- userId: ctx.session.user.id,- emoji: input.emoji,- },+ commentId: input.commentId,+ userId: ctx.session.user.id,+ emoji: input.emoji,+ projectId: input.projectId,},});+ if (deletedReaction.count === 0) {+ throw new TRPCError({+ code: "NOT_FOUND",+ message: "Reaction not found",+ });+ }+return;} catch (error) {logger.error("Failed to call commentReactions.remove", error);@@ -178,7 +186,10 @@ export const commentReactionsRouter = createTRPCRouter({});const reactions = await ctx.prisma.commentReaction.findMany({- where: { commentId: input.commentId },+ where: {+ commentId: input.commentId,+ projectId: input.projectId,+ },orderBy: { createdAt: "asc" },...(canSeeUserDetails && {include: {