Skip to content

Commit eb57f72

Browse files
authored
add email to application (#64)
* add email to application * add indexes
1 parent 87f47ce commit eb57f72

File tree

5 files changed

+101
-4
lines changed

5 files changed

+101
-4
lines changed

app/config/swaggerconfig.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,14 @@ const swaggerDefinition = {
133133
"phoneNumber": {
134134
"type": "string",
135135
"description": "Contact phone number",
136-
"pattern": "^\\+?[\\d\\s-]{10,}$",
137-
"example": "+1-555-123-4567",
138-
"unique": true
136+
"pattern": "^\\+?[1-9]\\d{1,14}$",
137+
"example": "+15551234567",
138+
},
139+
"email": {
140+
"type": "string",
141+
"description": "Contact email address",
142+
"pattern": "^[\\w.-]+@[\\w.-]+\\.\\w{2,}$",
143+
"example": "[email protected]"
139144
},
140145
"school": {
141146
"type": "string",

app/database/Prisma.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const applicationSchema = z.object({
4646
ethnicity: z.string().min(1, "Ethnicity is required"),
4747
gradYear: z.number().int().min(new Date().getFullYear(), "Graduation year must be current year or later"),
4848
phoneNumber: z.string().regex(/^\+?[0-9]{10,15}$/, "Phone number must be valid"),
49+
email: z.string().email("Email must be valid"),
4950
school: z.string().min(1, "School name is required"),
5051
city: z.string().min(1, "City is required"),
5152
state: z.string().min(1, "State is required"),
@@ -193,6 +194,7 @@ const userUpdateSchema = userSchema.omit({
193194
}).partial().strict();
194195
const applicationUpdateSchema = applicationSchema.omit({
195196
userId: true,
197+
email: true,
196198
applicationYear: true,
197199
id: true,
198200
status: true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
Warnings:
3+
4+
- You are about to drop the column `pronous` on the `Application` table. All the data in the column will be lost.
5+
- Added the required column `email` to the `Application` table without a default value. This is not possible if the table is not empty.
6+
- Added the required column `pronouns` to the `Application` table without a default value. This is not possible if the table is not empty.
7+
8+
*/
9+
-- DropIndex
10+
DROP INDEX "Application_phoneNumber_key";
11+
12+
-- AlterTable
13+
ALTER TABLE "Application" DROP COLUMN "pronous",
14+
ADD COLUMN "email" TEXT NOT NULL,
15+
ADD COLUMN "pronouns" TEXT NOT NULL;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-- CreateIndex
2+
CREATE INDEX "Application_userId_idx" ON "Application"("userId");
3+
4+
-- CreateIndex
5+
CREATE INDEX "Application_applicationYear_idx" ON "Application"("applicationYear");
6+
7+
-- CreateIndex
8+
CREATE INDEX "Application_status_idx" ON "Application"("status");
9+
10+
-- CreateIndex
11+
CREATE INDEX "Application_applicationYear_status_idx" ON "Application"("applicationYear", "status");
12+
13+
-- CreateIndex
14+
CREATE INDEX "Application_email_idx" ON "Application"("email");
15+
16+
-- CreateIndex
17+
CREATE INDEX "Judge_year_idx" ON "Judge"("year");
18+
19+
-- CreateIndex
20+
CREATE INDEX "Judge_accessCode_idx" ON "Judge"("accessCode");
21+
22+
-- CreateIndex
23+
CREATE INDEX "JudgingCriteria_year_idx" ON "JudgingCriteria"("year");
24+
25+
-- CreateIndex
26+
CREATE INDEX "JudgingCriteria_event_idx" ON "JudgingCriteria"("event");
27+
28+
-- CreateIndex
29+
CREATE INDEX "Project_year_idx" ON "Project"("year");
30+
31+
-- CreateIndex
32+
CREATE INDEX "Project_isWinner_idx" ON "Project"("isWinner");
33+
34+
-- CreateIndex
35+
CREATE INDEX "Project_year_isWinner_idx" ON "Project"("year", "isWinner");
36+
37+
-- CreateIndex
38+
CREATE INDEX "Project_track_idx" ON "Project"("track");
39+
40+
-- CreateIndex
41+
CREATE INDEX "Project_placement_idx" ON "Project"("placement");
42+
43+
-- CreateIndex
44+
CREATE INDEX "Score_totalScore_idx" ON "Score"("totalScore");
45+
46+
-- CreateIndex
47+
CREATE INDEX "Score_judgeId_idx" ON "Score"("judgeId");
48+
49+
-- CreateIndex
50+
CREATE INDEX "Score_projectId_idx" ON "Score"("projectId");
51+
52+
-- CreateIndex
53+
CREATE INDEX "Score_createdAt_idx" ON "Score"("createdAt");

prisma/schema.prisma

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ model Application {
2929
age Int
3030
ethnicity String
3131
gradYear Int
32-
phoneNumber String @unique
32+
phoneNumber String
33+
email String
3334
school String
3435
city String
3536
state String
@@ -48,6 +49,12 @@ model Application {
4849
user User @relation(fields: [userId], references: [id])
4950
userId String
5051
status Status @default(PENDING)
52+
53+
@@index([userId])
54+
@@index([applicationYear])
55+
@@index([status])
56+
@@index([applicationYear, status])
57+
@@index([email])
5158
}
5259

5360
model Project {
@@ -67,6 +74,12 @@ model Project {
6774
placement Int? // placement of project (1, 2, 3, ...)
6875
// possibly add points here
6976
scores Score[]
77+
78+
@@index([year])
79+
@@index([isWinner])
80+
@@index([year, isWinner])
81+
@@index([track])
82+
@@index([placement])
7083
}
7184

7285
model Judge {
@@ -79,6 +92,9 @@ model Judge {
7992
year Int?
8093
createdAt DateTime @default(now())
8194
updatedAt DateTime @updatedAt
95+
96+
@@index([year])
97+
@@index([accessCode])
8298
}
8399

84100
model Score {
@@ -95,6 +111,10 @@ model Score {
95111
updatedAt DateTime @updatedAt
96112
97113
@@unique([judgeId, projectId]) // Each judge can only score a project once
114+
@@index([totalScore])
115+
@@index([judgeId])
116+
@@index([projectId])
117+
@@index([createdAt])
98118
}
99119

100120
model JudgingCriteria {
@@ -106,6 +126,8 @@ model JudgingCriteria {
106126
updatedAt DateTime @updatedAt
107127
108128
@@unique([year, event]) // Each event-year combination has one set of criteria
129+
@@index([year])
130+
@@index([event])
109131
}
110132

111133
enum Role {

0 commit comments

Comments
 (0)