generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id Int @id @default(autoincrement()) username String @unique passwordHash String passwordSalt String sessions Session[] } model Session { token String @id @default(uuid()) createdAt DateTime @default(now()) user User @relation(fields: [userId], references: [id]) userId Int } enum SubmissionState { Queued InReview Correct Incorrect } enum SubmissionStateReason { BuildError TimeLimitExceeded IncorrectOverriddenAsCorrect SandboxError } model Submission { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) gradedAt DateTime? state SubmissionState stateReason SubmissionStateReason? stateReasonDetails String? 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? language Language } enum Language { Java CSharp } 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 @unique teams Team[] @relation("TeamContestRelation") problems Problem[] @relation("ProblemContestRelation") activeTeams ActiveTeam[] submissions Submission[] startTime DateTime? }