Created
October 1, 2021 23:22
-
-
Save RichardSPrins/58d1b7aedfcd9a6455f90d056f057291 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is your Prisma schema file, | |
// learn more about it in the docs: https://pris.ly/d/prisma-schema | |
datasource db { | |
provider = "postgres" | |
url = env("DATABASE_URL") | |
} | |
generator client { | |
provider = "prisma-client-js" | |
} | |
// -------------------------------------- | |
model User { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
name String? | |
email String @unique | |
hashedPassword String? | |
role Role @default(USER) | |
team Team? @relation(fields: [teamId], references: [id]) | |
teamId Int? | |
tokens Token[] | |
sessions Session[] | |
Coach Coach? | |
Student Student? | |
} | |
model Coach { | |
id Int @id @default(autoincrement()) | |
user User? @relation(fields: [userId], references: [id]) | |
userId Int? | |
hourlyRate Int? @default(0) | |
learningPaths LearningPath[] | |
tutorials Tutorial[] | |
CoachGameIntegration CoachGameIntegration[] | |
} | |
model Student { | |
id Int @id @default(autoincrement()) | |
user User? @relation(fields: [userId], references: [id]) | |
userId Int? | |
LearningPaths LearningPath[] | |
StudentGameIntegration StudentGameIntegration[] | |
Team Team? @relation(fields: [teamId], references: [id]) | |
teamId Int? | |
comments TutorialComments[] | |
StudentLearningPathStepProgress StudentLearningPathStepProgress[] | |
} | |
model StudentGameIntegration { | |
id Int @id @default(autoincrement()) | |
student Student? @relation(fields: [studentId], references: [id]) | |
studentId Int? | |
Game Game? @relation(fields: [gameId], references: [id]) | |
gameId Int? | |
username String | |
meta Json | |
} | |
model CoachGameIntegration { | |
id Int @id @default(autoincrement()) | |
coach Coach? @relation(fields: [coachId], references: [id]) | |
coachId Int? | |
Game Game? @relation(fields: [gameId], references: [id]) | |
gameId Int? | |
username String | |
meta Json | |
} | |
model Team { | |
id Int @id @default(autoincrement()) | |
name String | |
captain User? | |
members Student[] | |
logo String | |
} | |
model LearningPath { | |
id Int @id @default(autoincrement()) | |
title String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
activeStep Int @default(0) | |
steps LearningPathStep[] | |
Coach Coach? @relation(fields: [coachId], references: [id]) | |
coachId Int? | |
students Student[] | |
} | |
model LearningPathStep { | |
id Int @id @default(autoincrement()) | |
name String | |
goals String[] | |
LearningPath LearningPath? @relation(fields: [learningPathId], references: [id]) | |
learningPathId Int? | |
StudentLearningPathStepProgress StudentLearningPathStepProgress[] | |
} | |
model LearningPathStepComment { | |
id Int @id @default(autoincrement()) | |
} | |
model StudentLearningPathStepProgress { | |
id Int @id @default(autoincrement()) | |
student Student? @relation(fields: [studentId], references: [id]) | |
learningPathStep LearningPathStep? @relation(fields: [learningPathStepId], references: [id]) | |
studentId Int? | |
learningPathStepId Int? | |
progress Int | |
} | |
model Game { | |
id Int @id @default(autoincrement()) | |
name String | |
thumbnail String | |
bannerImage String? | |
tutorials Tutorial[] | |
players StudentGameIntegration[] | |
CoachGameIntegration CoachGameIntegration[] | |
} | |
model Tutorial { | |
id Int @id @default(autoincrement()) | |
author Coach? @relation(fields: [authorId], references: [id]) | |
authorId Int? | |
title String | |
body String | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
game Game? @relation(fields: [gameId], references: [id]) | |
gameId Int? | |
comments TutorialComments[] | |
} | |
model TutorialComments { | |
id Int @id @default(autoincrement()) | |
author Student? @relation(fields: [authorId], references: [id]) | |
authorId Int? | |
tutorial Tutorial? @relation(fields: [tutorialId], references: [id]) | |
tutorialId Int? | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
body String | |
rating StudentCoachRating? @relation(fields: [ratingId], references: [id]) | |
ratingId Int? | |
} | |
model StudentCoachRating { | |
id Int @id @default(autoincrement()) | |
overall Decimal | |
reliability Decimal | |
teachability Decimal | |
TutorialComments TutorialComments? | |
} | |
model Session { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
expiresAt DateTime? | |
handle String @unique | |
hashedSessionToken String? | |
antiCSRFToken String? | |
publicData String? | |
privateData String? | |
user User? @relation(fields: [userId], references: [id]) | |
userId Int? | |
} | |
model Token { | |
id Int @id @default(autoincrement()) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
hashedToken String | |
// type String | |
// See note below about TokenType enum | |
type TokenType | |
expiresAt DateTime | |
sentTo String | |
user User @relation(fields: [userId], references: [id]) | |
userId Int | |
@@unique([hashedToken, type]) | |
} | |
//ENUMS | |
// -------------------------------------- | |
// NOTE: It's highly recommended to use an enum for the token type | |
// but enums only work in Postgres. | |
// See: https://blitzjs.com/docs/database-overview#switch-to-postgresql | |
enum TokenType { | |
RESET_PASSWORD | |
} | |
enum Role { | |
USER | |
COACH | |
ADMIN | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment