gongxiangp2/prisma/schema.prisma
2025-10-26 09:11:04 +08:00

96 lines
2.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(uuid())
email String @unique
username String @unique
password String
role Role @default(USER)
isActive Boolean @default(false) // 是否激活,默认未激活
canDownload Boolean @default(true) // 是否允许下载,默认允许
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
materials Material[]
likes MaterialLike[]
@@map("users")
}
model Material {
id String @id @default(uuid())
previewUrl String // S3 URL for preview image
productModel String // SPU
categoryName String // 使用店铺
sceneName String // 场景类别
renderer String @default("CR") // 渲染器:CR/VR/其它
authorName String // 作者花名
zipFileName String // 压缩包文件名
zipFilePath String // 本地压缩包路径
zipFileSize BigInt @default(0) // 压缩包文件大小(字节)
downloadCount Int @default(0) // 下载次数
likeCount Int @default(0) // 点赞次数
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
likes MaterialLike[]
@@map("materials")
@@index([userId])
@@index([createdAt])
@@index([categoryName])
@@index([sceneName])
@@index([downloadCount])
@@index([likeCount])
}
model MaterialLike {
id String @id @default(uuid())
materialId String
userId String
createdAt DateTime @default(now())
material Material @relation(fields: [materialId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([materialId, userId]) // 确保一个用户只能点赞一次
@@map("material_likes")
@@index([materialId])
@@index([userId])
}
model Category {
id String @id @default(uuid())
name String @unique // 使用店铺名称
createdAt DateTime @default(now())
@@map("categories")
}
model Scene {
id String @id @default(uuid())
name String @unique // 场景类别名称
createdAt DateTime @default(now())
@@map("scenes")
}
enum Role {
USER
ADMIN
}