Initial commit: deardiary project setup
This commit is contained in:
101
backend/prisma/schema.prisma
Normal file
101
backend/prisma/schema.prisma
Normal file
@@ -0,0 +1,101 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
passwordHash String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
apiKeys ApiKey[]
|
||||
entries Entry[]
|
||||
journals Journal[]
|
||||
tasks Task[]
|
||||
settings Settings?
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
keyHash String @unique
|
||||
name String
|
||||
lastUsedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model Entry {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
date String
|
||||
type String
|
||||
content String
|
||||
mediaPath String?
|
||||
metadata String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId, date])
|
||||
@@index([date])
|
||||
}
|
||||
|
||||
model Journal {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
date String
|
||||
content String
|
||||
entryCount Int
|
||||
generatedAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
tasks Task[]
|
||||
|
||||
@@unique([userId, date])
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
model Task {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
journalId String
|
||||
type String @default("journal_generate")
|
||||
status String @default("pending")
|
||||
provider String
|
||||
model String?
|
||||
prompt String
|
||||
request String?
|
||||
response String?
|
||||
error String?
|
||||
createdAt DateTime @default(now())
|
||||
completedAt DateTime?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
journal Journal @relation(fields: [journalId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@index([journalId])
|
||||
}
|
||||
|
||||
model Settings {
|
||||
userId String @id
|
||||
aiProvider String @default("openai")
|
||||
aiApiKey String?
|
||||
aiModel String @default("gpt-4")
|
||||
aiBaseUrl String?
|
||||
journalPrompt String @default("You are a thoughtful journal writer. Based on the entries provided, write a reflective journal entry for this day in a warm, personal tone.")
|
||||
language String @default("en")
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
Reference in New Issue
Block a user