bw-hspc-contest-env/web/prisma/schema.prisma
2023-08-23 22:06:53 -04:00

88 lines
2.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
username String @unique
password String
sessions Session[]
}
model Session {
token String @id
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id])
userId Int
}
enum SubmissionState {
Queued
InReview
Correct
Incorrect
}
model Submission {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
gradedAt DateTime?
state SubmissionState
actualOutput String?
commitHash String
diff String?
message String?
team Team @relation(fields: [teamId], references: [id])
teamId Int
problem Problem @relation(fields: [problemId], references: [id])
problemId Int
contestId Int
contest Contest @relation(fields: [contestId], references: [id])
}
model Problem {
id Int @id @default(autoincrement())
friendlyName String @unique
pascalName String @unique
sampleInput String
sampleOutput String
realInput String
realOutput String
submissions Submission[]
contests Contest[] @relation("ProblemContestRelation")
}
model Team {
id Int @id @default(autoincrement())
name String @unique
submissions Submission[]
contests Contest[] @relation("TeamContestRelation")
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?
contestId Int
contest Contest @relation(fields: [contestId], references: [id])
}
model Contest {
id Int @id @default(autoincrement())
name String
teams Team[] @relation("TeamContestRelation")
problems Problem[] @relation("ProblemContestRelation")
activeTeams ActiveTeam[]
submissions Submission[]
startTime DateTime?
}