101 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			101 lines
		
	
	
	
		
			2.9 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| // 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"
 | |
| }
 | |
| 
 | |
| 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[]
 | |
| 
 | |
|   @@map("forms") // Map to the 'forms' table
 | |
| }
 | |
| 
 | |
| 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[]
 | |
| 
 | |
|   @@map("categories") // Map to the 'categories' table
 | |
| }
 | |
| 
 | |
| enum FieldType {
 | |
|   text
 | |
|   number
 | |
|   date
 | |
|   textarea
 | |
|   boolean
 | |
| }
 | |
| 
 | |
| 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)
 | |
|   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)
 | |
|   responseValues ResponseValue[]
 | |
| 
 | |
|   @@map("responses") // Map to the 'responses' table
 | |
| }
 | |
| 
 | |
| 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)
 | |
| 
 | |
|   @@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())
 | |
| }
 | |
| 
 | |
| model Setting {
 | |
|   key   String @id
 | |
|   value String
 | |
| 
 | |
|   @@map("settings") // Map to the 'settings' table
 | |
| }
 |