反爬虫优化,评论图片支持
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "CommentImage" (
|
||||
"id" TEXT NOT NULL,
|
||||
"commentId" TEXT NOT NULL,
|
||||
"url" TEXT NOT NULL,
|
||||
"order" INTEGER NOT NULL,
|
||||
"width" INTEGER,
|
||||
"height" INTEGER,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "CommentImage_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "CommentImage_commentId_order_idx" ON "CommentImage"("commentId", "order");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CommentImage_commentId_order_key" ON "CommentImage"("commentId", "order");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommentImage" ADD CONSTRAINT "CommentImage_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "Comment"("cid") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,41 @@
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."Comment" DROP CONSTRAINT "Comment_imagePostId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."Comment" DROP CONSTRAINT "Comment_userId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."Comment" DROP CONSTRAINT "Comment_videoId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."CommentImage" DROP CONSTRAINT "CommentImage_commentId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."ImageFile" DROP CONSTRAINT "ImageFile_postId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."ImagePost" DROP CONSTRAINT "ImagePost_authorId_fkey";
|
||||
|
||||
-- DropForeignKey
|
||||
ALTER TABLE "public"."Video" DROP CONSTRAINT "Video_authorId_fkey";
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Video" ADD CONSTRAINT "Video_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "Author"("sec_uid") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES "Video"("aweme_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_imagePostId_fkey" FOREIGN KEY ("imagePostId") REFERENCES "ImagePost"("aweme_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_userId_fkey" FOREIGN KEY ("userId") REFERENCES "CommentUser"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "CommentImage" ADD CONSTRAINT "CommentImage_commentId_fkey" FOREIGN KEY ("commentId") REFERENCES "Comment"("cid") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ImagePost" ADD CONSTRAINT "ImagePost_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "Author"("sec_uid") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ImageFile" ADD CONSTRAINT "ImageFile_postId_fkey" FOREIGN KEY ("postId") REFERENCES "ImagePost"("aweme_id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
+27
-6
@@ -49,7 +49,7 @@ model Video {
|
||||
cover_url String?
|
||||
|
||||
authorId String
|
||||
author Author @relation(fields: [authorId], references: [sec_uid])
|
||||
author Author @relation(fields: [authorId], references: [sec_uid], onDelete: Cascade)
|
||||
|
||||
comments Comment[]
|
||||
|
||||
@@ -87,13 +87,16 @@ model Comment {
|
||||
|
||||
// 可关联视频或图文中的一种
|
||||
videoId String?
|
||||
video Video? @relation(fields: [videoId], references: [aweme_id])
|
||||
video Video? @relation(fields: [videoId], references: [aweme_id], onDelete: Cascade)
|
||||
|
||||
imagePostId String?
|
||||
imagePost ImagePost? @relation(fields: [imagePostId], references: [aweme_id])
|
||||
imagePost ImagePost? @relation(fields: [imagePostId], references: [aweme_id], onDelete: Cascade)
|
||||
|
||||
userId String
|
||||
user CommentUser @relation(fields: [userId], references: [id])
|
||||
user CommentUser @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
// 评论下的贴纸/配图(统一按图片存储)
|
||||
images CommentImage[]
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
@@ -102,6 +105,24 @@ model Comment {
|
||||
@@index([imagePostId, created_at])
|
||||
}
|
||||
|
||||
// 评论图片(贴纸和配图统一保存在这里)
|
||||
model CommentImage {
|
||||
id String @id @default(cuid())
|
||||
commentId String
|
||||
comment Comment @relation(fields: [commentId], references: [cid], onDelete: Cascade)
|
||||
|
||||
url String
|
||||
order Int // 在该评论中的顺序(0 开始)
|
||||
width Int?
|
||||
height Int?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([commentId, order])
|
||||
@@unique([commentId, order])
|
||||
}
|
||||
|
||||
// 图片作品(图文)
|
||||
model ImagePost {
|
||||
aweme_id String @id
|
||||
@@ -115,7 +136,7 @@ model ImagePost {
|
||||
collect_count BigInt @default(0)
|
||||
|
||||
authorId String
|
||||
author Author @relation(fields: [authorId], references: [sec_uid])
|
||||
author Author @relation(fields: [authorId], references: [sec_uid], onDelete: Cascade)
|
||||
|
||||
tags String[]
|
||||
music_url String? // 背景音乐(已上传到 MinIO 的外链)
|
||||
@@ -137,7 +158,7 @@ model ImagePost {
|
||||
model ImageFile {
|
||||
id String @id @default(cuid())
|
||||
postId String
|
||||
post ImagePost @relation(fields: [postId], references: [aweme_id])
|
||||
post ImagePost @relation(fields: [postId], references: [aweme_id], onDelete: Cascade)
|
||||
url String
|
||||
order Int // 在作品中的顺序(从 0 开始)
|
||||
width Int?
|
||||
|
||||
Reference in New Issue
Block a user