226 lines
6.7 KiB
Text
226 lines
6.7 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
previewFeatures = ["fullTextSearchPostgres"]
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Form {
|
|
id Int @id @default(autoincrement())
|
|
title String
|
|
description String?
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
categories Category[]
|
|
responses Response[]
|
|
}
|
|
|
|
model Category {
|
|
id Int @id @default(autoincrement())
|
|
formId Int @map("form_id")
|
|
name String
|
|
sortOrder Int @default(0) @map("sort_order")
|
|
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
|
|
fields Field[]
|
|
}
|
|
|
|
enum FieldType {
|
|
text
|
|
number
|
|
date
|
|
textarea
|
|
boolean
|
|
}
|
|
|
|
model Field {
|
|
id Int @id @default(autoincrement())
|
|
categoryId Int @map("category_id")
|
|
label String
|
|
type FieldType
|
|
description String?
|
|
sortOrder Int @map("sort_order")
|
|
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
|
responseValues ResponseValue[]
|
|
}
|
|
|
|
model Response {
|
|
id Int @id @default(autoincrement())
|
|
formId Int @map("form_id")
|
|
submittedAt DateTime @default(now()) @map("submitted_at")
|
|
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
|
|
responseValues ResponseValue[]
|
|
}
|
|
|
|
model ResponseValue {
|
|
id Int @id @default(autoincrement())
|
|
responseId Int @map("response_id")
|
|
fieldId Int @map("field_id")
|
|
value String?
|
|
response Response @relation(fields: [responseId], references: [id], onDelete: Cascade)
|
|
field Field @relation(fields: [fieldId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model MantisSummary {
|
|
id Int @id @default(autoincrement())
|
|
summaryDate DateTime @unique @map("summary_date") @db.Date
|
|
summaryText String @map("summary_text")
|
|
generatedAt DateTime @default(now()) @map("generated_at")
|
|
}
|
|
|
|
model Setting {
|
|
key String @id
|
|
value String
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
username String @unique @db.Citext()
|
|
authenticators Authenticator[]
|
|
preferences UserPreference[]
|
|
|
|
email String? @unique @db.Citext()
|
|
fullName String?
|
|
}
|
|
|
|
model UserPreference {
|
|
id Int @id @default(autoincrement())
|
|
userId String @map("user_id")
|
|
key String
|
|
value String
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, key])
|
|
}
|
|
|
|
model Authenticator {
|
|
id String @id @default(uuid())
|
|
credentialID String @unique @map("credential_id")
|
|
credentialPublicKey Bytes @map("credential_public_key")
|
|
counter BigInt
|
|
credentialDeviceType String @map("credential_device_type")
|
|
credentialBackedUp Boolean @map("credential_backed_up")
|
|
transports String?
|
|
|
|
userId String @map("user_id")
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model ChatThread {
|
|
id String @id @default(uuid())
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
messages ChatMessage[]
|
|
}
|
|
|
|
model ChatMessage {
|
|
id String @id @default(uuid())
|
|
threadId String @map("thread_id")
|
|
sender String // 'user' or 'bot'
|
|
content String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
// Add this model for session storage
|
|
model Session {
|
|
id String @id
|
|
sid String @unique
|
|
data String
|
|
expiresAt DateTime @map("expires_at")
|
|
}
|
|
|
|
model Log {
|
|
id Int @id @default(autoincrement())
|
|
timestamp DateTime @default(now())
|
|
level String
|
|
message String
|
|
meta Json? // Optional field for additional structured data
|
|
}
|
|
|
|
// --- Mantis Models Start ---
|
|
|
|
model MantisIssue {
|
|
id Int @id @default(autoincrement())
|
|
title String
|
|
description String?
|
|
reporterUsername String? @map("reporter_username")
|
|
status String
|
|
priority String
|
|
severity String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
comments MantisComment[]
|
|
files MantisFile[]
|
|
notes MantisNote[] // Add relation to MantisNote
|
|
|
|
fts Unsupported("tsvector")?
|
|
|
|
@@index([reporterUsername])
|
|
@@index([status])
|
|
@@index([priority])
|
|
@@index([severity])
|
|
@@index([fts], map: "mantisissue_fts_idx", type: Gin) // Add this line
|
|
}
|
|
|
|
model MantisComment {
|
|
id Int @id @default(autoincrement())
|
|
mantisIssueId Int @map("mantis_issue_id")
|
|
senderUsername String? @map("sender_username")
|
|
comment String
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
|
|
mantisIssue MantisIssue @relation(fields: [mantisIssueId], references: [id], onDelete: Cascade)
|
|
attachments MantisAttachment[]
|
|
fts Unsupported("tsvector")?
|
|
|
|
@@index([fts], map: "mantiscomment_fts_idx", type: Gin) // Add this line
|
|
}
|
|
|
|
model MantisAttachment {
|
|
id Int @id @default(autoincrement())
|
|
commentId Int @map("comment_id")
|
|
filename String
|
|
url String // Store path or URL to the file
|
|
mimeType String? @map("mime_type")
|
|
size Int?
|
|
uploadedAt DateTime @default(now()) @map("uploaded_at")
|
|
|
|
comment MantisComment @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
// New model for user-uploaded files to S3
|
|
model MantisFile {
|
|
id Int @id @default(autoincrement())
|
|
mantisIssueId Int @map("mantis_issue_id")
|
|
filename String
|
|
fileKey String @map("file_key") // S3 object key
|
|
mimeType String? @map("mime_type")
|
|
size Int?
|
|
uploadedBy String? @map("uploaded_by") // Username of uploader
|
|
uploadedAt DateTime @default(now()) @map("uploaded_at")
|
|
description String?
|
|
|
|
mantisIssue MantisIssue @relation(fields: [mantisIssueId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([mantisIssueId])
|
|
}
|
|
|
|
// New model for internal notes
|
|
model MantisNote {
|
|
id Int @id @default(autoincrement())
|
|
mantisIssueId Int @map("mantis_issue_id")
|
|
content String
|
|
createdBy String @map("created_by") // Username of the creator
|
|
createdAt DateTime @default(now()) @map("created_at")
|
|
updatedAt DateTime @updatedAt @map("updated_at")
|
|
|
|
mantisIssue MantisIssue @relation(fields: [mantisIssueId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([mantisIssueId])
|
|
@@index([createdBy])
|
|
}
|
|
|
|
// --- Mantis Models End ---
|