Skip to content

Commit

Permalink
changed bookmark from timestamp to video
Browse files Browse the repository at this point in the history
  • Loading branch information
nimit9 committed Mar 18, 2024
1 parent 5b48793 commit d462566
Show file tree
Hide file tree
Showing 30 changed files with 462 additions and 1,050 deletions.
64 changes: 35 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"@discordjs/next": "^0.1.1-dev.1673526225-a580768.0",
"@prisma/client": "^5.6.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-navigation-menu": "^1.1.4",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-tooltip": "^1.0.7",
"@types/jsonwebtoken": "^9.0.5",
"axios": "^1.6.2",
"class-variance-authority": "^0.7.0",
Expand Down
22 changes: 0 additions & 22 deletions prisma/migrations/20240316193028_add_bookmarks/migration.sql

This file was deleted.

22 changes: 22 additions & 0 deletions prisma/migrations/20240318200949_add_bookmark/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE "Bookmark" (
"id" SERIAL NOT NULL,
"userId" TEXT NOT NULL,
"contentId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"courseId" INTEGER NOT NULL,

CONSTRAINT "Bookmark_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Bookmark_contentId_key" ON "Bookmark"("contentId");

-- AddForeignKey
ALTER TABLE "Bookmark" ADD CONSTRAINT "Bookmark_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Bookmark" ADD CONSTRAINT "Bookmark_contentId_fkey" FOREIGN KEY ("contentId") REFERENCES "Content"("id") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Bookmark" ADD CONSTRAINT "Bookmark_courseId_fkey" FOREIGN KEY ("courseId") REFERENCES "Course"("id") ON DELETE CASCADE ON UPDATE CASCADE;
28 changes: 12 additions & 16 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ model Course {
slug String
content CourseContent[]
purchasedBy UserPurchases[]
bookmarks VideoBookmark[]
bookmarks Bookmark[]
}

model UserPurchases {
Expand Down Expand Up @@ -50,7 +50,7 @@ model Content {
notionMetadataId Int?
comments Comment[]
commentsCount Int @default(0)
bookmarks VideoBookmark[]
bookmark Bookmark?
}

model CourseContent {
Expand Down Expand Up @@ -128,7 +128,7 @@ model User {
votes Vote[]
discordConnect DiscordConnect?
disableDrm Boolean @default(false)
bookmarks VideoBookmark[]
bookmarks Bookmark[]
}

model DiscordConnect {
Expand Down Expand Up @@ -158,18 +158,15 @@ model VideoProgress {
@@unique([contentId, userId])
}

model VideoBookmark {
id Int @id @default(autoincrement())
userId String
contentId Int
courseId Int
timestamp Int
description String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
model Bookmark {
id Int @id @default(autoincrement())
userId String
contentId Int @unique
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
content Content @relation(fields: [contentId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
courseId Int
course Course @relation(fields: [courseId], references: [id], onDelete: Cascade)
}

model Comment {
Expand Down Expand Up @@ -214,4 +211,3 @@ enum CommentType {
INTRO
DEFAULT
}

Loading

0 comments on commit d462566

Please sign in to comment.