first commit
This commit is contained in:
102
prisma/schema.prisma
Normal file
102
prisma/schema.prisma
Normal file
@@ -0,0 +1,102 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../app/generated/prisma"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
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?
|
||||
}
|
||||
|
||||
model contentDayView{
|
||||
id String @id @default(uuid())
|
||||
contentId String
|
||||
date DateTime
|
||||
views Int
|
||||
validViews Int
|
||||
premiumViews Int
|
||||
watchTime Int
|
||||
@@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[]
|
||||
}
|
||||
|
||||
model noticeBoard{
|
||||
id String @id @default(uuid())
|
||||
title String
|
||||
content String @db.LongText
|
||||
tag String
|
||||
pubDate DateTime
|
||||
isDeleted Boolean @default(false)
|
||||
}
|
||||
|
||||
|
||||
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>
|
||||
새로운 마이그레이션 파일 생성
|
||||
npx prisma generate
|
||||
프리즈마 클라이언트 생성
|
||||
npx prisma db push
|
||||
데이터베이스 동기화
|
||||
npx prisma studio
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user