judge4c/prisma/schema.prisma

125 lines
2.6 KiB
Plaintext
Raw Normal View History

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum Role {
ADMIN
TEACHER
STUDENT
GUEST
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
password String?
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
// Optional for WebAuthn support
Authenticator Authenticator[]
role Role @default(GUEST)
problems Problem[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
enum Difficulty {
EASY
MEDIUM
HARD
}
model Problem {
id String @id @default(cuid())
title String
description String
solution String
difficulty Difficulty @default(EASY)
published Boolean @default(false)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
templates Template[]
@@index([userId])
@@index([difficulty])
}
enum EditorLanguage {
c
cpp
}
model Template {
language EditorLanguage
template String
problemId String
problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade)
@@id([problemId, language])
}
model Account {
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([provider, providerAccountId])
}
model Session {
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model VerificationToken {
identifier String
token String
expires DateTime
@@id([identifier, token])
}
// Optional for WebAuthn support
model Authenticator {
credentialID String @unique
userId String
providerAccountId String
credentialPublicKey String
counter Int
credentialDeviceType String
credentialBackedUp Boolean
transports String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@id([userId, credentialID])
}