119 lines
2.9 KiB
Plaintext
119 lines
2.9 KiB
Plaintext
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
// =====================
|
|
// AUTH
|
|
// =====================
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
email String @unique
|
|
hashedPassword String
|
|
avatar String?
|
|
bio String?
|
|
plan String @default("free") // free | pro | master
|
|
aiActionsUsed Int @default(0)
|
|
dailyWordGoal Int @default(500)
|
|
writingStreak Int @default(0)
|
|
lastWriteDate DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
projects Project[]
|
|
sessions Session[]
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
// =====================
|
|
// DATA
|
|
// =====================
|
|
model Project {
|
|
id String @id @default(cuid())
|
|
title String
|
|
author String
|
|
settings Json?
|
|
styleGuide String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
chapters Chapter[]
|
|
entities Entity[]
|
|
ideas Idea[]
|
|
plotNodes PlotNode[]
|
|
plotConnections PlotConnection[]
|
|
}
|
|
|
|
model Chapter {
|
|
id String @id @default(cuid())
|
|
title String
|
|
content String @default("")
|
|
summary String?
|
|
orderIndex Int @default(0)
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Entity {
|
|
id String @id @default(cuid())
|
|
type String
|
|
name String
|
|
description String @default("")
|
|
details String @default("")
|
|
storyContext String?
|
|
attributes Json?
|
|
customValues Json?
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Idea {
|
|
id String @id @default(cuid())
|
|
title String
|
|
description String @default("")
|
|
status String @default("todo")
|
|
category String @default("plot")
|
|
createdAt DateTime @default(now())
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model PlotNode {
|
|
id String @id @default(cuid())
|
|
x Float
|
|
y Float
|
|
title String
|
|
description String @default("")
|
|
color String @default("#3b82f6")
|
|
type String?
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model PlotConnection {
|
|
id String @id @default(cuid())
|
|
source String
|
|
target String
|
|
|
|
projectId String
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|