93 lines
2.0 KiB
Plaintext
93 lines
2.0 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
datasource db {
|
|
provider = "postgres"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
model Form {
|
|
title String
|
|
choisesQuestions ChoisesQuestion[]
|
|
inputQuestions InputQuestion[]
|
|
submissions FormSubmission[]
|
|
dateCreated DateTime @default(now())
|
|
author User @relation(fields: [userId], references: [id])
|
|
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
}
|
|
|
|
model ChoisesQuestion {
|
|
title String
|
|
variants Variant[]
|
|
type ChoiseType
|
|
number Int
|
|
|
|
id Int @id @default(autoincrement())
|
|
Form Form? @relation(fields: [formId], references: [id])
|
|
formId Int?
|
|
}
|
|
|
|
model Variant {
|
|
text String
|
|
|
|
id Int @id @default(autoincrement())
|
|
ChoisesQuestion ChoisesQuestion? @relation(fields: [choisesQuestionId], references: [id])
|
|
choisesQuestionId Int?
|
|
}
|
|
|
|
model InputQuestion {
|
|
title String
|
|
number Int
|
|
|
|
id Int @id @default(autoincrement())
|
|
Form Form? @relation(fields: [formId], references: [id])
|
|
formId Int?
|
|
}
|
|
|
|
enum ChoiseType {
|
|
SELECT
|
|
CHECK
|
|
CHOOSE
|
|
}
|
|
|
|
model User {
|
|
name String
|
|
email String @unique @default("test@mail.com")
|
|
forms Form[]
|
|
|
|
id Int @id @default(autoincrement())
|
|
formsSubmissions FormSubmission[]
|
|
}
|
|
|
|
model FormSubmission {
|
|
answers Answer[]
|
|
date DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
id Int @id @default(autoincrement())
|
|
userId Int
|
|
Form Form? @relation(fields: [formId], references: [id])
|
|
formId Int?
|
|
}
|
|
|
|
model Answer {
|
|
userInput String?
|
|
userChoise Int?
|
|
type AnswerType
|
|
|
|
id Int @id @default(autoincrement())
|
|
FormSubmission FormSubmission? @relation(fields: [formSubmissionId], references: [id])
|
|
formSubmissionId Int?
|
|
}
|
|
|
|
enum AnswerType {
|
|
INPUT
|
|
CHOISE
|
|
}
|