diff --git a/prisma/schema.prisma b/prisma/schema.prisma deleted file mode 100644 index ca8e4431c..000000000 --- a/prisma/schema.prisma +++ /dev/null @@ -1,363 +0,0 @@ -generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"] -} - -datasource db { - provider = "postgresql" - url = env("DATABASE_URL") -} - -model Course { - id Int @id @default(autoincrement()) - appxCourseId String - discordRoleId String - title String - imageUrl String - description String - openToEveryone Boolean @default(false) - slug String - discordOauthUrl String @default("") - content CourseContent[] - purchasedBy UserPurchases[] - certificate Certificate[] - certIssued Boolean @default(false) -} - -model UserPurchases { - user User @relation(fields: [userId], references: [id]) - userId String - course Course @relation(fields: [courseId], references: [id]) - courseId Int - assignedAt DateTime @default(now()) - - @@id([userId, courseId]) -} - -model Content { - id Int @id @default(autoincrement()) - type String @default("folder") - title String - hidden Boolean @default(false) - description String? - thumbnail String? - parentId Int? - parent Content? @relation("ContentToContent", fields: [parentId], references: [id]) - videoProgress VideoProgress[] - children Content[] @relation("ContentToContent") - courses CourseContent[] - createdAt DateTime @default(now()) - VideoMetadata VideoMetadata? - NotionMetadata NotionMetadata? - notionMetadataId Int? - comments Comment[] - commentsCount Int @default(0) - bookmark Bookmark[] -} - -model CourseContent { - course Course @relation(fields: [courseId], references: [id]) - courseId Int - content Content @relation(fields: [contentId], references: [id]) - contentId Int - - @@id([courseId, contentId]) -} - -model Certificate { - id String @id @default(cuid()) - slug String @default("certId") - user User @relation(fields: [userId], references: [id]) - userId String - course Course @relation(fields: [courseId], references: [id]) - courseId Int - - @@unique([userId, courseId]) -} - -model NotionMetadata { - id Int @id @default(autoincrement()) - contentId Int - content Content @relation(fields: [contentId], references: [id]) - notionId String - - @@unique([contentId]) -} - -model VideoMetadata { - id Int @id @default(autoincrement()) - contentId Int - appxVideoId String? - appxVideoJSON Json? - video_1080p_mp4_1 String? // Link to 1080p mp4 quality video variant 1 - video_1080p_mp4_2 String? // Link to 1080p mp4 quality video variant 2 - video_1080p_mp4_3 String? // Link to 1080p mp4 quality video variant 3 - video_1080p_mp4_4 String? // Link to 1080p mp4 quality video variant 4 - video_1080p_1 String? // Link to 1080p quality video variant 1 - video_1080p_2 String? // Link to 1080p quality video variant 2 - video_1080p_3 String? // Link to 1080p quality video variant 3 - video_1080p_4 String? // Link to 1080p quality video variant 4 - video_720p_mp4_1 String? // Link to 720p mp4 quality video variant 1 - video_720p_mp4_2 String? // Link to 720p mp4 quality video variant 2 - video_720p_mp4_3 String? // Link to 720p mp4 quality video variant 3 - video_720p_mp4_4 String? // Link to 720p mp4 quality video variant 4 - video_720p_1 String? // Link to 720p quality video variant 1 - video_720p_2 String? // Link to 720p quality video variant 2 - video_720p_3 String? // Link to 720p quality video variant 3 - video_720p_4 String? // Link to 720p quality video variant 4 - video_360p_mp4_1 String? // Link to 360p mp4 quality video variant 1 - video_360p_mp4_2 String? // Link to 360p mp4 quality video variant 2 - video_360p_mp4_3 String? // Link to 360p mp4 quality video variant 3 - video_360p_mp4_4 String? // Link to 360p mp4 quality video variant 4 - video_360p_1 String? // Link to 360p quality video variant 1 - video_360p_2 String? // Link to 360p quality video variant 2 - video_360p_3 String? // Link to 360p quality video variant 3 - video_360p_4 String? // Link to 360p quality video variant 4 - subtitles String? // Link to subtitles file - subtitle_tried Int @default(0) //Count of subtitle transcoding tries - segments Json? - content Content @relation(fields: [contentId], references: [id]) - slides String? // link to slides - thumbnail_mosiac_url String? - duration Int? - migration_status MigrationStatus @default(NOT_MIGRATED) - migration_pickup_time DateTime? - migrated_video_1080p_mp4_1 String? - migrated_video_360p_mp4_1 String? - migrated_video_720p_mp4_1 String? - original_mp4_url String? - transcoded Boolean @default(false) - - @@unique([contentId]) -} - -model Session { - id String @id @default(cuid()) - sessionToken String @unique - userId String - expires DateTime - user User @relation(fields: [userId], references: [id], onDelete: Cascade) -} - -model User { - id String @id @default(cuid()) - name String? - email String? @unique - token String? - sessions Session[] - purchases UserPurchases[] - videoProgress VideoProgress[] - comments Comment[] - votes Vote[] - discordConnect DiscordConnect? - disableDrm Boolean @default(false) - bunnyProxyEnabled Boolean @default(false) - bookmarks Bookmark[] - password String? - appxUserId String? - appxUsername String? - appxAuthToken String? - questions Question[] - answers Answer[] - certificate Certificate[] - upiIds UpiId[] @relation("UserUpiIds") - solanaAddresses SolanaAddress[] @relation("UserSolanaAddresses") - githubUser GitHubLink? @relation("UserGithub") - bounties BountySubmission[] -} - -model GitHubLink { - id String @id @default(cuid()) - userId String @unique - user User @relation("UserGithub", fields: [userId], references: [id], onDelete: Cascade) - githubId String - username String - avatarUrl String? - access_token String - profileUrl String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} - -model UpiId { - id Int @id @default(autoincrement()) - value String @db.VarChar(256) - userId String - user User @relation("UserUpiIds", fields: [userId], references: [id]) - - @@unique([userId, value]) -} - -model SolanaAddress { - id Int @id @default(autoincrement()) - value String @db.Char(44) - userId String - user User @relation("UserSolanaAddresses", fields: [userId], references: [id]) - - @@unique([userId, value]) -} - -model DiscordConnect { - id String @id @default(cuid()) - username String - discordId String @unique - userId String @unique - user User @relation(fields: [userId], references: [id], onDelete: Cascade) -} - -model DiscordConnectBulk { - id String @id @default(cuid()) - username String - discordId String - userId String - cohortId String @default("") -} - -model VideoProgress { - id Int @id @default(autoincrement()) - userId String - contentId Int - currentTimestamp Int - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - content Content @relation(fields: [contentId], references: [id], onDelete: Cascade) - markAsCompleted Boolean @default(false) - updatedAt DateTime @default(now()) @updatedAt - - @@unique([contentId, userId]) -} - -model Bookmark { - id Int @id @default(autoincrement()) - userId String - contentId Int - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - content Content @relation(fields: [contentId], references: [id]) - createdAt DateTime @default(now()) -} - -model Comment { - id Int @id @default(autoincrement()) - content String - commentType CommentType @default(DEFAULT) - approved Boolean @default(false) - contentId Int - commentedOn Content @relation(fields: [contentId], references: [id]) - parentId Int? - parent Comment? @relation("ParentComment", fields: [parentId], references: [id]) - children Comment[] @relation("ParentComment") - userId String - user User @relation(fields: [userId], references: [id]) - upvotes Int @default(0) - downvotes Int @default(0) - repliesCount Int @default(0) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - votes Vote[] - isPinned Boolean @default(false) -} - -model Question { - id Int @id @default(autoincrement()) - title String - content String - slug String @unique - createdAt DateTime @default(now()) - author User @relation(fields: [authorId], references: [id]) - authorId String - upvotes Int @default(0) - downvotes Int @default(0) - totalanswers Int @default(0) - answers Answer[] - votes Vote[] - tags String[] - updatedAt DateTime @updatedAt - - @@index([authorId]) -} - -model Answer { - id Int @id @default(autoincrement()) - content String - createdAt DateTime @default(now()) - question Question @relation(fields: [questionId], references: [id]) - questionId Int - author User @relation(fields: [authorId], references: [id]) - authorId String - votes Vote[] - upvotes Int @default(0) - downvotes Int @default(0) - totalanswers Int @default(0) - parentId Int? - responses Answer[] @relation("AnswerToAnswer") - parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id]) - updatedAt DateTime @updatedAt - - @@index([questionId]) - @@index([authorId]) - @@index([parentId]) -} - -model Vote { - id Int @id @default(autoincrement()) - questionId Int? - question Question? @relation(fields: [questionId], references: [id]) - answerId Int? - answer Answer? @relation(fields: [answerId], references: [id]) - commentId Int? - comment Comment? @relation(fields: [commentId], references: [id]) - userId String - user User @relation(fields: [userId], references: [id]) - voteType VoteType - createdAt DateTime @default(now()) - - @@unique([questionId, userId]) - @@unique([answerId, userId]) - @@unique([commentId, userId]) -} - -model Event { - id Int @id @default(autoincrement()) - title String - start DateTime - end DateTime - videoLink String? - notes String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} - -model BountySubmission { - id String @id @default(uuid()) - prLink String - paymentMethod String - status String @default("pending") - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - amount Float @default(0) - userId String - user User @relation(fields: [userId], references: [id]) - - @@unique([userId, prLink]) -} - -enum VoteType { - UPVOTE - DOWNVOTE -} - -enum PostType { - QUESTION - ANSWER -} - -enum CommentType { - INTRO - DEFAULT -} - -enum MigrationStatus { - NOT_MIGRATED - IN_PROGRESS - MIGRATED - MIGRATION_ERROR -} diff --git a/prisma/schema/bounty.prisma b/prisma/schema/bounty.prisma new file mode 100644 index 000000000..8855a8b50 --- /dev/null +++ b/prisma/schema/bounty.prisma @@ -0,0 +1,13 @@ +model BountySubmission { + id String @id @default(uuid()) + prLink String + paymentMethod String + status String @default("pending") + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + amount Float @default(0) + userId String + user User @relation(fields: [userId], references: [id]) + + @@unique([userId, prLink]) +} diff --git a/prisma/schema/community.prisma b/prisma/schema/community.prisma new file mode 100644 index 000000000..9985bf149 --- /dev/null +++ b/prisma/schema/community.prisma @@ -0,0 +1,79 @@ +model Comment { + id Int @id @default(autoincrement()) + content String + commentType CommentType @default(DEFAULT) + approved Boolean @default(false) + contentId Int + commentedOn Content @relation(fields: [contentId], references: [id]) + parentId Int? + parent Comment? @relation("ParentComment", fields: [parentId], references: [id]) + children Comment[] @relation("ParentComment") + userId String + user User @relation(fields: [userId], references: [id]) + upvotes Int @default(0) + downvotes Int @default(0) + repliesCount Int @default(0) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + votes Vote[] + isPinned Boolean @default(false) +} + +model Question { + id Int @id @default(autoincrement()) + title String + content String + slug String @unique + createdAt DateTime @default(now()) + author User @relation(fields: [authorId], references: [id]) + authorId String + upvotes Int @default(0) + downvotes Int @default(0) + totalanswers Int @default(0) + answers Answer[] + votes Vote[] + tags String[] + updatedAt DateTime @updatedAt + + @@index([authorId]) +} + +model Answer { + id Int @id @default(autoincrement()) + content String + createdAt DateTime @default(now()) + question Question @relation(fields: [questionId], references: [id]) + questionId Int + author User @relation(fields: [authorId], references: [id]) + authorId String + votes Vote[] + upvotes Int @default(0) + downvotes Int @default(0) + totalanswers Int @default(0) + parentId Int? + responses Answer[] @relation("AnswerToAnswer") + parent Answer? @relation("AnswerToAnswer", fields: [parentId], references: [id]) + updatedAt DateTime @updatedAt + + @@index([questionId]) + @@index([authorId]) + @@index([parentId]) +} + +model Vote { + id Int @id @default(autoincrement()) + questionId Int? + question Question? @relation(fields: [questionId], references: [id]) + answerId Int? + answer Answer? @relation(fields: [answerId], references: [id]) + commentId Int? + comment Comment? @relation(fields: [commentId], references: [id]) + userId String + user User @relation(fields: [userId], references: [id]) + voteType VoteType + createdAt DateTime @default(now()) + + @@unique([questionId, userId]) + @@unique([answerId, userId]) + @@unique([commentId, userId]) +} diff --git a/prisma/schema/content.prisma b/prisma/schema/content.prisma new file mode 100644 index 000000000..fd5cf993d --- /dev/null +++ b/prisma/schema/content.prisma @@ -0,0 +1,107 @@ +model Content { + id Int @id @default(autoincrement()) + type String @default("folder") + title String + hidden Boolean @default(false) + description String? + thumbnail String? + parentId Int? + parent Content? @relation("ContentToContent", fields: [parentId], references: [id]) + videoProgress VideoProgress[] + children Content[] @relation("ContentToContent") + courses CourseContent[] + createdAt DateTime @default(now()) + VideoMetadata VideoMetadata? + NotionMetadata NotionMetadata? + notionMetadataId Int? + comments Comment[] + commentsCount Int @default(0) + bookmark Bookmark[] +} + +model CourseContent { + course Course @relation(fields: [courseId], references: [id]) + courseId Int + content Content @relation(fields: [contentId], references: [id]) + contentId Int + + @@id([courseId, contentId]) +} + +model VideoMetadata { + id Int @id @default(autoincrement()) + contentId Int + appxVideoId String? + appxVideoJSON Json? + video_1080p_mp4_1 String? // Link to 1080p mp4 quality video variant 1 + video_1080p_mp4_2 String? // Link to 1080p mp4 quality video variant 2 + video_1080p_mp4_3 String? // Link to 1080p mp4 quality video variant 3 + video_1080p_mp4_4 String? // Link to 1080p mp4 quality video variant 4 + video_1080p_1 String? // Link to 1080p quality video variant 1 + video_1080p_2 String? // Link to 1080p quality video variant 2 + video_1080p_3 String? // Link to 1080p quality video variant 3 + video_1080p_4 String? // Link to 1080p quality video variant 4 + video_720p_mp4_1 String? // Link to 720p mp4 quality video variant 1 + video_720p_mp4_2 String? // Link to 720p mp4 quality video variant 2 + video_720p_mp4_3 String? // Link to 720p mp4 quality video variant 3 + video_720p_mp4_4 String? // Link to 720p mp4 quality video variant 4 + video_720p_1 String? // Link to 720p quality video variant 1 + video_720p_2 String? // Link to 720p quality video variant 2 + video_720p_3 String? // Link to 720p quality video variant 3 + video_720p_4 String? // Link to 720p quality video variant 4 + video_360p_mp4_1 String? // Link to 360p mp4 quality video variant 1 + video_360p_mp4_2 String? // Link to 360p mp4 quality video variant 2 + video_360p_mp4_3 String? // Link to 360p mp4 quality video variant 3 + video_360p_mp4_4 String? // Link to 360p mp4 quality video variant 4 + video_360p_1 String? // Link to 360p quality video variant 1 + video_360p_2 String? // Link to 360p quality video variant 2 + video_360p_3 String? // Link to 360p quality video variant 3 + video_360p_4 String? // Link to 360p quality video variant 4 + subtitles String? // Link to subtitles file + subtitle_tried Int @default(0) //Count of subtitle transcoding tries + segments Json? + content Content @relation(fields: [contentId], references: [id]) + slides String? // link to slides + thumbnail_mosiac_url String? + duration Int? + migration_status MigrationStatus @default(NOT_MIGRATED) + migration_pickup_time DateTime? + migrated_video_1080p_mp4_1 String? + migrated_video_360p_mp4_1 String? + migrated_video_720p_mp4_1 String? + original_mp4_url String? + transcoded Boolean @default(false) + + @@unique([contentId]) +} + +model NotionMetadata { + id Int @id @default(autoincrement()) + contentId Int + content Content @relation(fields: [contentId], references: [id]) + notionId String + + @@unique([contentId]) +} + +model VideoProgress { + id Int @id @default(autoincrement()) + userId String + contentId Int + currentTimestamp Int + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + content Content @relation(fields: [contentId], references: [id], onDelete: Cascade) + markAsCompleted Boolean @default(false) + updatedAt DateTime @default(now()) @updatedAt + + @@unique([contentId, userId]) +} + +model Bookmark { + id Int @id @default(autoincrement()) + userId String + contentId Int + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + content Content @relation(fields: [contentId], references: [id]) + createdAt DateTime @default(now()) +} diff --git a/prisma/schema/course.prisma b/prisma/schema/course.prisma new file mode 100644 index 000000000..2262aa8f3 --- /dev/null +++ b/prisma/schema/course.prisma @@ -0,0 +1,36 @@ +model Course { + id Int @id @default(autoincrement()) + appxCourseId String + discordRoleId String + title String + imageUrl String + description String + openToEveryone Boolean @default(false) + slug String + discordOauthUrl String @default("") + content CourseContent[] + purchasedBy UserPurchases[] + certificate Certificate[] + certIssued Boolean @default(false) +} + +model UserPurchases { + user User @relation(fields: [userId], references: [id]) + userId String + course Course @relation(fields: [courseId], references: [id]) + courseId Int + assignedAt DateTime @default(now()) + + @@id([userId, courseId]) +} + +model Certificate { + id String @id @default(cuid()) + slug String @default("certId") + user User @relation(fields: [userId], references: [id]) + userId String + course Course @relation(fields: [courseId], references: [id]) + courseId Int + + @@unique([userId, courseId]) +} diff --git a/prisma/schema/enums.prisma b/prisma/schema/enums.prisma new file mode 100644 index 000000000..1e59bc9ce --- /dev/null +++ b/prisma/schema/enums.prisma @@ -0,0 +1,21 @@ +enum VoteType { + UPVOTE + DOWNVOTE +} + +enum PostType { + QUESTION + ANSWER +} + +enum CommentType { + INTRO + DEFAULT +} + +enum MigrationStatus { + NOT_MIGRATED + IN_PROGRESS + MIGRATED + MIGRATION_ERROR +} diff --git a/prisma/schema/event.prisma b/prisma/schema/event.prisma new file mode 100644 index 000000000..f99ea76d9 --- /dev/null +++ b/prisma/schema/event.prisma @@ -0,0 +1,10 @@ +model Event { + id Int @id @default(autoincrement()) + title String + start DateTime + end DateTime + videoLink String? + notes String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} diff --git a/prisma/schema/schema.prisma b/prisma/schema/schema.prisma new file mode 100644 index 000000000..9cb737c09 --- /dev/null +++ b/prisma/schema/schema.prisma @@ -0,0 +1,10 @@ +generator client { + provider = "prisma-client-js" + binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"] + previewFeatures = ["prismaSchemaFolder"] +} + +datasource db { + provider = "postgresql" + url = env("DATABASE_URL") +} diff --git a/prisma/schema/user.prisma b/prisma/schema/user.prisma new file mode 100644 index 000000000..c48e943e8 --- /dev/null +++ b/prisma/schema/user.prisma @@ -0,0 +1,81 @@ +model User { + id String @id @default(cuid()) + name String? + email String? @unique + token String? + sessions Session[] + purchases UserPurchases[] + videoProgress VideoProgress[] + comments Comment[] + votes Vote[] + discordConnect DiscordConnect? + disableDrm Boolean @default(false) + bunnyProxyEnabled Boolean @default(false) + bookmarks Bookmark[] + password String? + appxUserId String? + appxUsername String? + appxAuthToken String? + questions Question[] + answers Answer[] + certificate Certificate[] + upiIds UpiId[] @relation("UserUpiIds") + solanaAddresses SolanaAddress[] @relation("UserSolanaAddresses") + githubUser GitHubLink? @relation("UserGithub") + bounties BountySubmission[] +} + +model Session { + id String @id @default(cuid()) + sessionToken String @unique + userId String + expires DateTime + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model DiscordConnect { + id String @id @default(cuid()) + username String + discordId String @unique + userId String @unique + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model DiscordConnectBulk { + id String @id @default(cuid()) + username String + discordId String + userId String + cohortId String @default("") +} + +model GitHubLink { + id String @id @default(cuid()) + userId String @unique + user User @relation("UserGithub", fields: [userId], references: [id], onDelete: Cascade) + githubId String + username String + avatarUrl String? + access_token String + profileUrl String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model UpiId { + id Int @id @default(autoincrement()) + value String @db.VarChar(256) + userId String + user User @relation("UserUpiIds", fields: [userId], references: [id]) + + @@unique([userId, value]) +} + +model SolanaAddress { + id Int @id @default(autoincrement()) + value String @db.Char(44) + userId String + user User @relation("UserSolanaAddresses", fields: [userId], references: [id]) + + @@unique([userId, value]) +} diff --git a/tsconfig.json b/tsconfig.json index adf349623..c9fcce441 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,7 +37,7 @@ "**/*.ts", "**/*.tsx", ".next/types/**/*.ts" - ], +, "prisma/schema/user.prisma" ], "exclude": [ "node_modules" ]