Changed form submissions list logic, added user's forms to user fetching
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# Migration `20201104091229-renamed-user-form-submissions-name`
|
||||
|
||||
This migration has been generated by Dm1tr1y147 at 11/4/2020, 2:12:29 PM.
|
||||
You can check out the [state of the schema](./schema.prisma) after the migration.
|
||||
|
||||
## Database Steps
|
||||
|
||||
```sql
|
||||
|
||||
```
|
||||
|
||||
## Changes
|
||||
|
||||
```diff
|
||||
diff --git schema.prisma schema.prisma
|
||||
migration 20201009145620-add-user-email..20201104091229-renamed-user-form-submissions-name
|
||||
--- datamodel.dml
|
||||
+++ datamodel.dml
|
||||
@@ -2,9 +2,9 @@
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
datasource db {
|
||||
provider = "postgres"
|
||||
- url = "***"
|
||||
+ url = "***"
|
||||
}
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
@@ -60,10 +60,10 @@
|
||||
name String
|
||||
email String @unique @default("test@mail.com")
|
||||
forms Form[]
|
||||
- id Int @id @default(autoincrement())
|
||||
- formsSubmissions FormSubmission[]
|
||||
+ id Int @id @default(autoincrement())
|
||||
+ formSubmissions FormSubmission[]
|
||||
}
|
||||
model FormSubmission {
|
||||
answers Answer[]
|
||||
```
|
||||
|
||||
|
@@ -0,0 +1,92 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
datasource db {
|
||||
provider = "postgres"
|
||||
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())
|
||||
formSubmissions 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
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "0.3.14-fixed",
|
||||
"steps": [
|
||||
{
|
||||
"tag": "CreateField",
|
||||
"model": "User",
|
||||
"field": "formSubmissions",
|
||||
"type": "FormSubmission",
|
||||
"arity": "List"
|
||||
},
|
||||
{
|
||||
"tag": "DeleteField",
|
||||
"model": "User",
|
||||
"field": "formsSubmissions"
|
||||
}
|
||||
]
|
||||
}
|
@@ -3,4 +3,5 @@
|
||||
20201006125838-initial-migration
|
||||
20201006185953-improved-schema-structure
|
||||
20201007134933-fix-optional-values
|
||||
20201009145620-add-user-email
|
||||
20201009145620-add-user-email
|
||||
20201104091229-renamed-user-form-submissions-name
|
Reference in New Issue
Block a user