feat(i18n): Add new comment-related translations in multiple languages

This commit is contained in:
Fatih Kadir Akın
2025-12-18 15:00:25 +03:00
parent 0918a7790f
commit 6a30e1b201
27 changed files with 2083 additions and 21 deletions

View File

@@ -0,0 +1,86 @@
-- CreateEnum
CREATE TYPE "NotificationType" AS ENUM ('COMMENT', 'REPLY');
-- CreateTable
CREATE TABLE "comments" (
"id" TEXT NOT NULL,
"content" TEXT NOT NULL,
"score" INTEGER NOT NULL DEFAULT 0,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"promptId" TEXT NOT NULL,
"authorId" TEXT NOT NULL,
"parentId" TEXT,
"flagged" BOOLEAN NOT NULL DEFAULT false,
"flaggedAt" TIMESTAMP(3),
"flaggedBy" TEXT,
"deletedAt" TIMESTAMP(3),
CONSTRAINT "comments_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "comment_votes" (
"userId" TEXT NOT NULL,
"commentId" TEXT NOT NULL,
"value" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "comment_votes_pkey" PRIMARY KEY ("userId","commentId")
);
-- CreateTable
CREATE TABLE "notifications" (
"id" TEXT NOT NULL,
"type" "NotificationType" NOT NULL,
"read" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"userId" TEXT NOT NULL,
"actorId" TEXT,
"promptId" TEXT,
"commentId" TEXT,
CONSTRAINT "notifications_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "comments_promptId_idx" ON "comments"("promptId");
-- CreateIndex
CREATE INDEX "comments_authorId_idx" ON "comments"("authorId");
-- CreateIndex
CREATE INDEX "comments_parentId_idx" ON "comments"("parentId");
-- CreateIndex
CREATE INDEX "comment_votes_userId_idx" ON "comment_votes"("userId");
-- CreateIndex
CREATE INDEX "comment_votes_commentId_idx" ON "comment_votes"("commentId");
-- CreateIndex
CREATE INDEX "notifications_userId_idx" ON "notifications"("userId");
-- CreateIndex
CREATE INDEX "notifications_userId_read_idx" ON "notifications"("userId", "read");
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_promptId_fkey" FOREIGN KEY ("promptId") REFERENCES "prompts"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comments" ADD CONSTRAINT "comments_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comment_votes" ADD CONSTRAINT "comment_votes_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "comments"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "comment_votes" ADD CONSTRAINT "comment_votes_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_userId_fkey" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "notifications" ADD CONSTRAINT "notifications_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;

View File

@@ -33,6 +33,10 @@ model User {
prompts Prompt[] @relation("PromptAuthor")
sessions Session[]
contributions Prompt[] @relation("PromptContributors")
comments Comment[] @relation("CommentAuthor")
commentVotes CommentVote[]
notifications Notification[] @relation("NotificationRecipient")
notificationsActed Notification[] @relation("NotificationActor")
@@map("users")
}
@@ -106,6 +110,7 @@ model Prompt {
tags PromptTag[]
versions PromptVersion[]
votes PromptVote[]
comments Comment[]
author User @relation("PromptAuthor", fields: [authorId], references: [id], onDelete: Cascade)
category Category? @relation(fields: [categoryId], references: [id])
contributors User[] @relation("PromptContributors")
@@ -266,6 +271,67 @@ model WebhookConfig {
@@map("webhook_configs")
}
model Comment {
id String @id @default(cuid())
content String
score Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
promptId String
authorId String
parentId String?
flagged Boolean @default(false)
flaggedAt DateTime?
flaggedBy String?
deletedAt DateTime?
prompt Prompt @relation(fields: [promptId], references: [id], onDelete: Cascade)
author User @relation("CommentAuthor", fields: [authorId], references: [id], onDelete: Cascade)
parent Comment? @relation("CommentReplies", fields: [parentId], references: [id], onDelete: Cascade)
replies Comment[] @relation("CommentReplies")
votes CommentVote[]
@@index([promptId])
@@index([authorId])
@@index([parentId])
@@map("comments")
}
model CommentVote {
userId String
commentId String
value Int // 1 for upvote, -1 for downvote
createdAt DateTime @default(now())
comment Comment @relation(fields: [commentId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, commentId])
@@index([userId])
@@index([commentId])
@@map("comment_votes")
}
model Notification {
id String @id @default(cuid())
type NotificationType
read Boolean @default(false)
createdAt DateTime @default(now())
userId String
actorId String?
promptId String?
commentId String?
user User @relation("NotificationRecipient", fields: [userId], references: [id], onDelete: Cascade)
actor User? @relation("NotificationActor", fields: [actorId], references: [id], onDelete: SetNull)
@@index([userId])
@@index([userId, read])
@@map("notifications")
}
enum NotificationType {
COMMENT
REPLY
}
enum UserRole {
ADMIN
USER