Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Warnings:
- You are about to drop the column `downVotes` on the `aiWorkflowRunItem` table. All the data in the column will be lost.
- You are about to drop the column `upVotes` on the `aiWorkflowRunItem` table. All the data in the column will be lost.
- You are about to drop the column `downVotes` on the `aiWorkflowRunItemComment` table. All the data in the column will be lost.
- You are about to drop the column `upVotes` on the `aiWorkflowRunItemComment` table. All the data in the column will be lost.
*/
-- CreateEnum
CREATE TYPE "VoteType" AS ENUM ('UPVOTE', 'DOWNVOTE');

-- AlterTable
ALTER TABLE "aiWorkflowRunItem" DROP COLUMN "downVotes",
DROP COLUMN "upVotes";

-- AlterTable
ALTER TABLE "aiWorkflowRunItemComment" DROP COLUMN "downVotes",
DROP COLUMN "upVotes";

-- CreateTable
CREATE TABLE "aiWorkflowRunItemVote" (
"id" VARCHAR(14) NOT NULL DEFAULT nanoid(),
"workflowRunItemId" VARCHAR(14) NOT NULL,
"voteType" "VoteType" NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdBy" TEXT,

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

-- CreateTable
CREATE TABLE "aiWorkflowRunItemCommentVote" (
"id" VARCHAR(14) NOT NULL DEFAULT nanoid(),
"workflowRunItemCommentId" VARCHAR(14) NOT NULL,
"voteType" "VoteType" NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdBy" TEXT,

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

-- CreateIndex
CREATE INDEX "aiWorkflowRunItemVote_workflowRunItemId_idx" ON "aiWorkflowRunItemVote"("workflowRunItemId");

-- CreateIndex
CREATE INDEX "aiWorkflowRunItemCommentVote_workflowRunItemCommentId_idx" ON "aiWorkflowRunItemCommentVote"("workflowRunItemCommentId");

-- AddForeignKey
ALTER TABLE "aiWorkflowRunItemVote" ADD CONSTRAINT "aiWorkflowRunItemVote_workflowRunItemId_fkey" FOREIGN KEY ("workflowRunItemId") REFERENCES "aiWorkflowRunItem"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "aiWorkflowRunItemCommentVote" ADD CONSTRAINT "aiWorkflowRunItemCommentVote_workflowRunItemCommentId_fkey" FOREIGN KEY ("workflowRunItemCommentId") REFERENCES "aiWorkflowRunItemComment"("id") ON DELETE CASCADE ON UPDATE CASCADE;
37 changes: 33 additions & 4 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,35 @@ model llmModel {
workflows aiWorkflow[]
}

model aiWorkflowRunItemVote {
id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14)
workflowRunItemId String @db.VarChar(14)
voteType VoteType
createdAt DateTime @default(now()) @db.Timestamp(3)
createdBy String? @db.Text

item aiWorkflowRunItem @relation(fields: [workflowRunItemId], references: [id], onDelete: Cascade)

@@index([workflowRunItemId])
}

model aiWorkflowRunItemCommentVote {
id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14)
workflowRunItemCommentId String @db.VarChar(14)
voteType VoteType
createdAt DateTime @default(now()) @db.Timestamp(3)
createdBy String? @db.Text

comment aiWorkflowRunItemComment @relation(fields: [workflowRunItemCommentId], references: [id], onDelete: Cascade)

@@index([workflowRunItemCommentId])
}

enum VoteType {
UPVOTE
DOWNVOTE
}

model aiWorkflow {
id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14)
name String @unique @db.VarChar
Expand Down Expand Up @@ -690,24 +719,22 @@ model aiWorkflowRunItem {
workflowRunId String @db.VarChar(14)
scorecardQuestionId String @db.VarChar(14)
content String @db.Text
upVotes Int @default(0)
downVotes Int @default(0)
questionScore Float? @db.DoublePrecision
createdAt DateTime @db.Timestamp(3)
createdBy String? @db.Text

run aiWorkflowRun @relation(fields: [workflowRunId], references: [id])
question scorecardQuestion @relation(fields: [scorecardQuestionId], references: [id])
comments aiWorkflowRunItemComment[]

votes aiWorkflowRunItemVote[]
}

model aiWorkflowRunItemComment {
id String @id @default(dbgenerated("nanoid()")) @db.VarChar(14)
workflowRunItemId String @db.VarChar(14)
userId String @db.Text
content String @db.Text
upVotes Int @default(0)
downVotes Int @default(0)
parentId String? @db.VarChar(14)
createdAt DateTime @default(now()) @db.Timestamp(3)
createdBy String? @db.Text
Expand All @@ -717,4 +744,6 @@ model aiWorkflowRunItemComment {
item aiWorkflowRunItem @relation(fields: [workflowRunItemId], references: [id])
parent aiWorkflowRunItemComment? @relation("CommentHierarchy", fields: [parentId], references: [id])
replies aiWorkflowRunItemComment[] @relation("CommentHierarchy")

votes aiWorkflowRunItemCommentVote[]
}