Skip to content

Commit 9b16365

Browse files
authored
Feat: (user application) additional user information part 1 (#248)
* update seed file to include populateUserApplications add user application (onboarding) form questions (question model) add pageNumber field update prisma schema - add UserApplication table * fix input type in forms/user-app seed * (seed/user-app.ts) update responses to include responses to all questions * (prisma) generate migration file * fix test errors * update gitignore to ignore codebuddy * update gitignore and remove codebuddy files * remove duplicate line in .gitignore
1 parent 5fca8a9 commit 9b16365

17 files changed

Lines changed: 472 additions & 89 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,5 @@ pgadmin-data
139139
.idea/
140140

141141
# Misc system generated
142-
.DS_Store
142+
.DS_Store
143+
/.codebuddy/
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Warnings:
3+
4+
- A unique constraint covering the columns `[userApplicationId]` on the table `User` will be added. If there are existing duplicate values, this will fail.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "OptionChoice" ADD COLUMN "description" TEXT,
9+
ADD COLUMN "order" INTEGER;
10+
11+
-- AlterTable
12+
ALTER TABLE "Question" ADD COLUMN "pageNumber" INTEGER;
13+
14+
-- AlterTable
15+
ALTER TABLE "User" ADD COLUMN "userApplicationId" INTEGER;
16+
17+
-- CreateTable
18+
CREATE TABLE "UserApplication" (
19+
"id" SERIAL NOT NULL,
20+
"userId" UUID NOT NULL,
21+
"formId" INTEGER,
22+
"responseGroupId" INTEGER,
23+
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
24+
"updatedAt" TIMESTAMP(3) NOT NULL,
25+
26+
CONSTRAINT "UserApplication_pkey" PRIMARY KEY ("id")
27+
);
28+
29+
-- CreateIndex
30+
CREATE UNIQUE INDEX "UserApplication_userId_key" ON "UserApplication"("userId");
31+
32+
-- CreateIndex
33+
CREATE UNIQUE INDEX "UserApplication_responseGroupId_key" ON "UserApplication"("responseGroupId");
34+
35+
-- CreateIndex
36+
CREATE UNIQUE INDEX "User_userApplicationId_key" ON "User"("userApplicationId");
37+
38+
-- AddForeignKey
39+
ALTER TABLE "UserApplication" ADD CONSTRAINT "UserApplication_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
40+
41+
-- AddForeignKey
42+
ALTER TABLE "UserApplication" ADD CONSTRAINT "UserApplication_formId_fkey" FOREIGN KEY ("formId") REFERENCES "Form"("id") ON DELETE SET NULL ON UPDATE CASCADE;
43+
44+
-- AddForeignKey
45+
ALTER TABLE "UserApplication" ADD CONSTRAINT "UserApplication_responseGroupId_fkey" FOREIGN KEY ("responseGroupId") REFERENCES "ResponseGroup"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

prisma/schema/form.prisma

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ model Form {
2323
formResponseMeetings FormResponseMeeting[]
2424
soloProjects SoloProject[]
2525
voyageApplications VoyageApplication[]
26+
userApplications UserApplication[]
2627
}
2728

2829
model Question {
@@ -40,13 +41,14 @@ model Question {
4041
optionGroup OptionGroup? @relation(fields: [optionGroupId], references: [id])
4142
parentQuestionId Int?
4243
parentQuestion Question? @relation("QuestionSubQuestion", fields: [parentQuestionId], references: [id])
44+
pageNumber Int?
45+
parseConfig Json?
4346
4447
createdAt DateTime @default(now()) @db.Timestamptz()
4548
updatedAt DateTime @updatedAt
4649
4750
responses Response[]
4851
subQuestions Question[] @relation("QuestionSubQuestion")
49-
parseConfig Json?
5052
}
5153

5254
model InputType {
@@ -68,22 +70,22 @@ model OptionGroup {
6870
6971
optionChoices OptionChoice[]
7072
questions Question[]
71-
7273
}
7374

7475
model OptionChoice {
7576
id Int @id @default(autoincrement())
7677
optionGroupId Int
7778
optionGroup OptionGroup @relation(fields: [optionGroupId], references: [id], onDelete: Cascade)
7879
text String
79-
order Int?
8080
description String?
81+
order Int?
82+
parseConfig Json?
83+
8184
8285
createdAt DateTime @default(now()) @db.Timestamptz()
8386
updatedAt DateTime @updatedAt
8487
8588
responses Response[]
86-
parseConfig Json?
8789
}
8890

8991
model Response {
@@ -114,6 +116,8 @@ model ResponseGroup {
114116
formResponseMeeting FormResponseMeeting?
115117
formResponseCheckin FormResponseCheckin?
116118
formResponseVoyageProject FormResponseVoyageProject?
119+
120+
UserApplication UserApplication[]
117121
}
118122

119123
model FormResponseMeeting {

prisma/schema/user.prisma

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ model Gender {
1212
}
1313

1414
model User {
15-
id String @id @default(uuid()) @db.Uuid
16-
email String @unique
17-
emailVerified Boolean @default(false)
18-
password String
19-
firstName String?
20-
lastName String?
21-
avatar String?
22-
gender Gender? @relation(fields: [genderId], references: [id], onDelete: SetNull, onUpdate: Cascade)
23-
genderId Int?
24-
countryCode String?
25-
timezone String?
26-
comment String?
27-
hasCompletedAssessment Boolean @default(false)
28-
refreshToken String[]
15+
id String @id @default(uuid()) @db.Uuid
16+
email String @unique
17+
emailVerified Boolean @default(false)
18+
password String
19+
firstName String?
20+
lastName String?
21+
avatar String?
22+
gender Gender? @relation(fields: [genderId], references: [id], onDelete: SetNull, onUpdate: Cascade)
23+
genderId Int?
24+
countryCode String?
25+
timezone String?
26+
comment String?
27+
hasCompletedAssessment Boolean @default(false)
28+
refreshToken String[]
2929
3030
createdAt DateTime @default(now()) @db.Timestamptz()
3131
updatedAt DateTime @updatedAt
@@ -40,6 +40,8 @@ model User {
4040
roles UserRole[]
4141
oAuthProfiles UserOAuthProfile[]
4242
comments Comment[]
43+
userApplicationId Int? @unique
44+
userApplication UserApplication?
4345
}
4446

4547
model Role {

prisma/schema/userApp.prisma

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// === User Application ===
2+
model UserApplication {
3+
id Int @id @default(autoincrement())
4+
userId String @unique @db.Uuid()
5+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
6+
formId Int?
7+
form Form? @relation(fields: [formId], references: [id], onDelete: SetNull)
8+
responseGroupId Int? @unique
9+
responseGroup ResponseGroup? @relation(fields: [responseGroupId], references: [id], onDelete: Restrict)
10+
11+
createdAt DateTime @default(now()) @db.Timestamptz()
12+
updatedAt DateTime @updatedAt
13+
}

prisma/seed/data/genders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default [
99
},
1010
{
1111
abbreviation: "T",
12-
description: "trans",
12+
description: "transgender",
1313
},
1414
{
1515
abbreviation: "NB",

prisma/seed/data/input-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@ export default [
3535
{
3636
name: "noInputText",
3737
},
38+
{
39+
name: "dropdown",
40+
},
41+
{
42+
name: "dropdownCountryCode",
43+
},
3844
];

prisma/seed/forms/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { populateVoyageSubmissionForm } from "./voyage-project-submission";
88
import { prisma } from "../prisma-client";
99
import { populateCheckinFormResponse } from "../responses/checkinform-responses";
1010
import { populateVoyageProjectSubmissionFormResponses } from "../responses/voyage-project-form-response";
11+
import { populateUserApplicationForm } from "@Prisma/seed/forms/user-app";
1112

1213
export const populateFormsAndResponses = async () => {
1314
// test option choices for Voyage Application form
@@ -63,6 +64,7 @@ export const populateFormsAndResponses = async () => {
6364
await populateVoyageApplicationForm();
6465
await populateVoyageSubmissionForm();
6566
await populateVoyageProjectSubmissionFormResponses();
67+
await populateUserApplicationForm();
6668

6769
console.log("Forms, Questions and Responses populated.");
6870
};

0 commit comments

Comments
 (0)