middle
This commit is contained in:
@@ -14,16 +14,54 @@ datasource db {
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model content{
|
||||
// user
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String
|
||||
icon String @default("")
|
||||
isApproved Boolean @default(false)
|
||||
createtime DateTime @default(now())
|
||||
RegisgerCode String @default("")
|
||||
|
||||
// Many-to-many: a user can have many handles
|
||||
handles Handle[]
|
||||
// One-to-many: a user can have many register channels
|
||||
registerChannels RegisterChannel[]
|
||||
}
|
||||
|
||||
model RegisterChannel {
|
||||
id String @id @default(uuid())
|
||||
handle String
|
||||
// Relation: many register channels belong to one user
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
}
|
||||
|
||||
// handle
|
||||
model Handle {
|
||||
id String @id @default(uuid())
|
||||
handle String @unique
|
||||
constPerView Float @default(1)
|
||||
// Relations
|
||||
contents Content[]
|
||||
// Many-to-many: a handle can belong to many users
|
||||
users User[]
|
||||
}
|
||||
|
||||
// content
|
||||
model Content{
|
||||
id String @id @default(uuid())
|
||||
subject String
|
||||
pubDate DateTime
|
||||
views Int
|
||||
validViews Int
|
||||
premiumViews Int
|
||||
watchTime Int
|
||||
// Back relation: a content may link to at most one handle
|
||||
contentHandle ContentHandle?
|
||||
// views Int
|
||||
// validViews Int
|
||||
// premiumViews Int
|
||||
// watchTime Int
|
||||
// Relation: many contents belong to one handle
|
||||
handleId String
|
||||
handle Handle @relation(fields: [handleId], references: [id])
|
||||
// Back relation: one content has many day views
|
||||
dayViews contentDayView[]
|
||||
}
|
||||
|
||||
model contentDayView{
|
||||
@@ -34,21 +72,13 @@ model contentDayView{
|
||||
validViews Int
|
||||
premiumViews Int
|
||||
watchTime Int
|
||||
// Relation: many day views belong to one content
|
||||
content Content @relation(fields: [contentId], references: [id])
|
||||
@@unique([contentId, date])
|
||||
}
|
||||
|
||||
|
||||
model userHandle {
|
||||
id String @id @default(uuid())
|
||||
email String
|
||||
handle String @unique
|
||||
icon String @default("")
|
||||
isApproved Boolean @default(false)
|
||||
createtime DateTime @default(now())
|
||||
// Relation: a handle can be linked to many contents
|
||||
contentLinks ContentHandle[]
|
||||
}
|
||||
|
||||
// notice
|
||||
model noticeBoard{
|
||||
id String @id @default(uuid())
|
||||
title String
|
||||
@@ -59,35 +89,6 @@ model noticeBoard{
|
||||
}
|
||||
|
||||
|
||||
model registerChannel {
|
||||
id String @id @default(uuid())
|
||||
email String
|
||||
handle String
|
||||
randomcode String
|
||||
createtime DateTime @default(now())
|
||||
}
|
||||
|
||||
model costPerView{
|
||||
id Int @id @default(1)
|
||||
costPerView Float
|
||||
}
|
||||
|
||||
|
||||
// Mapping table: Each content can be linked to at most one handle (unique contentId)
|
||||
// A handle can have many contents
|
||||
model ContentHandle {
|
||||
id String @id @default(uuid())
|
||||
contentId String @unique
|
||||
handle String
|
||||
|
||||
// Relations
|
||||
content content @relation(fields: [contentId], references: [id])
|
||||
user userHandle @relation(fields: [handle], references: [handle])
|
||||
|
||||
@@index([handle])
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
npx prisma migrate dev --name <migration_name>
|
||||
|
||||
Reference in New Issue
Block a user