Adds in initial migration, recommends ESLint VS Code extension and sets up defaults to format with ESLint on save and use ESLint as the general formatter
This commit is contained in:
parent
86967b26cd
commit
a857c3da07
9 changed files with 217 additions and 219 deletions
|
@ -1,9 +1,3 @@
|
|||
// 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"
|
||||
}
|
||||
|
@ -20,8 +14,6 @@ model Form {
|
|||
createdAt DateTime @default(now()) @map("created_at")
|
||||
categories Category[]
|
||||
responses Response[]
|
||||
|
||||
@@map("forms") // Map to the 'forms' table
|
||||
}
|
||||
|
||||
model Category {
|
||||
|
@ -31,8 +23,6 @@ model Category {
|
|||
sortOrder Int @default(0) @map("sort_order")
|
||||
form Form @relation(fields: [formId], references: [id], onDelete: Cascade)
|
||||
fields Field[]
|
||||
|
||||
@@map("categories") // Map to the 'categories' table
|
||||
}
|
||||
|
||||
enum FieldType {
|
||||
|
@ -44,26 +34,22 @@ enum FieldType {
|
|||
}
|
||||
|
||||
model Field {
|
||||
id Int @id @default(autoincrement())
|
||||
categoryId Int @map("category_id")
|
||||
label String
|
||||
type FieldType // Using Prisma Enum based on CHECK constraint
|
||||
description String?
|
||||
sortOrder Int @map("sort_order")
|
||||
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
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[]
|
||||
|
||||
@@map("fields") // Map to the 'fields' table
|
||||
}
|
||||
|
||||
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)
|
||||
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[]
|
||||
|
||||
@@map("responses") // Map to the 'responses' table
|
||||
}
|
||||
|
||||
model ResponseValue {
|
||||
|
@ -73,66 +59,58 @@ model ResponseValue {
|
|||
value String?
|
||||
response Response @relation(fields: [responseId], references: [id], onDelete: Cascade)
|
||||
field Field @relation(fields: [fieldId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("response_values") // Map to the 'response_values' table
|
||||
}
|
||||
|
||||
model MantisSummary {
|
||||
id Int @id @default(autoincrement())
|
||||
summaryDate DateTime @unique @db.Date @map("summary_date")
|
||||
summaryText String @map("summary_text")
|
||||
generatedAt DateTime @default(now()) @map("generated_at")
|
||||
|
||||
@@map("mantis_summaries") // Map to the 'mantis_summaries' table
|
||||
}
|
||||
|
||||
model EmailSummary {
|
||||
id Int @id @default(autoincrement())
|
||||
summaryDate DateTime @unique @db.Date
|
||||
summaryText String
|
||||
generatedAt DateTime @default(now())
|
||||
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
|
||||
|
||||
@@map("settings") // Map to the 'settings' table
|
||||
}
|
||||
|
||||
// Added for WebAuthn
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
username String @unique
|
||||
id String @id @default(uuid())
|
||||
username String @unique @db.Citext()
|
||||
authenticators Authenticator[]
|
||||
preferences UserPreference[]
|
||||
|
||||
@@map("users")
|
||||
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") // Base64URL encoded
|
||||
credentialID String @unique @map("credential_id")
|
||||
credentialPublicKey Bytes @map("credential_public_key")
|
||||
counter BigInt
|
||||
credentialDeviceType String @map("credential_device_type") // 'singleDevice' or 'multiDevice'
|
||||
credentialDeviceType String @map("credential_device_type")
|
||||
credentialBackedUp Boolean @map("credential_backed_up")
|
||||
transports String? // Comma-separated list like "internal,hybrid"
|
||||
transports String?
|
||||
|
||||
userId String @map("user_id")
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("authenticators")
|
||||
}
|
||||
|
||||
// --- Add Chat Models ---
|
||||
|
||||
model ChatThread {
|
||||
id String @id @default(uuid())
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
messages ChatMessage[]
|
||||
|
||||
@@map("chat_threads")
|
||||
}
|
||||
|
||||
model ChatMessage {
|
||||
|
@ -142,6 +120,4 @@ model ChatMessage {
|
|||
content String
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
thread ChatThread @relation(fields: [threadId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("chat_messages")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue