Files
plume/prisma/schema.prisma

142 lines
3.5 KiB
Plaintext

datasource db {
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
// =====================
// AUTH & SUBSCRIPTIONS
// =====================
model Plan {
id String @id // e.g., 'free', 'pro', 'master'
name String @unique
displayName String
price Float
description String
maxProjects Int // -1 for unlimited
maxAiActions Int // -1 for unlimited
features String[]
isPopular Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
users User[]
}
model User {
id String @id @default(cuid())
name String?
email String @unique
hashedPassword String
bio String?
avatar String?
// Legacy string plan (temporarily kept to avoid DB drop errors)
plan String @default("free")
// New Subscription
planId String? @default("free")
subscriptionPlan Plan? @relation(fields: [planId], references: [id])
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)
}