bw-hspc-contest-env/web/prisma/schema.prisma

80 lines
2.0 KiB
Plaintext
Raw Normal View History

2023-04-27 22:26:54 -04:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
2023-05-06 12:36:52 -04:00
id Int @id @default(autoincrement())
username String @unique
password String
sessions Session[]
2023-04-28 13:42:16 -04:00
}
model Session {
token String @id
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
userId Int
2023-04-27 22:26:54 -04:00
}
2023-04-28 10:30:46 -04:00
enum SubmissionState {
InReview
Correct
Incorrect
}
model Submission {
2023-04-29 15:27:51 -04:00
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
gradedAt DateTime?
state SubmissionState
actualOutput String
message String?
team Team @relation(fields: [teamId], references: [id])
teamId Int
problem Problem @relation(fields: [problemId], references: [id])
problemId Int
2023-04-28 10:30:46 -04:00
}
2023-04-28 20:06:28 -04:00
model Problem {
2023-04-29 13:21:23 -04:00
id Int @id @default(autoincrement())
friendlyName String @unique
2023-04-28 20:06:28 -04:00
sampleInput String
sampleOutput String
realInput String
realOutput String
2023-05-06 12:36:52 -04:00
submissions Submission[]
2023-04-29 21:09:39 -04:00
contests Contest[] @relation("ProblemContestRelation")
2023-04-28 20:06:28 -04:00
}
2023-04-29 11:42:35 -04:00
model Team {
2023-04-29 13:21:23 -04:00
id Int @id @default(autoincrement())
name String @unique
Submission Submission[]
2023-04-29 21:09:39 -04:00
contests Contest[] @relation("TeamContestRelation")
2023-05-06 00:01:27 -04:00
password String
activeTeam ActiveTeam?
}
model ActiveTeam {
id Int @id @default(autoincrement())
teamId Int @unique
team Team @relation(fields: [teamId], references: [id])
sessionToken String? @unique
sessionCreatedAt DateTime?
2023-05-06 12:36:52 -04:00
contestId Int
contest Contest @relation(fields: [contestId], references: [id])
2023-04-29 21:09:39 -04:00
}
model Contest {
2023-05-06 12:36:52 -04:00
id Int @id @default(autoincrement())
name String
teams Team[] @relation("TeamContestRelation")
problems Problem[] @relation("ProblemContestRelation")
activeTeams ActiveTeam[]
2023-04-29 11:42:35 -04:00
}