-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ExerciseComment database table #2404
Changes from 1 commit
d7d2f5e
488fe1a
f5a3e8f
ebf3d8c
9c43845
b15b3c8
fbb00cd
76e3554
0955ccc
e660fab
9bacfc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- CreateTable | ||
CREATE TABLE "Discussion" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMPTZ(6) NOT NULL, | ||
"authorId" INTEGER NOT NULL, | ||
"exerciseId" INTEGER NOT NULL, | ||
"userPic" TEXT NOT NULL, | ||
"content" TEXT NOT NULL, | ||
"parentId" INTEGER, | ||
|
||
CONSTRAINT "Discussion_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Discussion" ADD CONSTRAINT "Discussion_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Discussion" ADD CONSTRAINT "Discussion_exerciseId_fkey" FOREIGN KEY ("exerciseId") REFERENCES "exercises"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Discussion" ADD CONSTRAINT "Discussion_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Discussion"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Discussion" ALTER COLUMN "userPic" DROP NOT NULL; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- DropForeignKey | ||
ALTER TABLE "Discussion" DROP CONSTRAINT "Discussion_authorId_fkey"; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Discussion" ADD CONSTRAINT "Discussion_authorId_fkey" FOREIGN KEY ("authorId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
flacial marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,7 @@ model User { | |
submissionsReviewed Submission[] @relation("userReviewedSubmissions") | ||
submissions Submission[] @relation("userSubmissions") | ||
userLessons UserLesson[] | ||
discussions Discussion[] | ||
|
||
@@map("users") | ||
} | ||
|
@@ -193,6 +194,7 @@ model Exercise { | |
flaggedBy User? @relation("flaggedExercises", fields: [flaggedById], references: [id]) | ||
module Module @relation(fields: [moduleId], references: [id], onDelete: Cascade) | ||
submissions ExerciseSubmission[] | ||
discussions Discussion[] | ||
|
||
@@map("exercises") | ||
} | ||
|
@@ -207,3 +209,19 @@ model ExerciseSubmission { | |
|
||
@@map("exerciseSubmissions") | ||
} | ||
|
||
model Discussion { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little bit confused by naming this table There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets finalize all these details before implementation. After implementing this model, we should not have to be touching this model in the backend anymore to finish implementing a MVP for the discussions flow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What do you mean by "finalize"? And when is a design doc is considered complete? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are following a design doc, all of the architecture should be decided upon before implementation. By finalized details I mean complete design doc. What a complete design doc looks like will differ depending on what feature the design doc was made for. Here are good tips on design docs, it's also in our engineering practices For this discussions flow design doc, enough should be outlined such that the backend and frontend can start work in parallel. If we are still deciding on how the backend should be setup, then that means the frontend can't be worked on yet since the frontend relies on how the backend is setup |
||
id Int @id @default(autoincrement()) | ||
createdAt DateTime @default(now()) @db.Timestamptz(6) | ||
updatedAt DateTime @updatedAt @db.Timestamptz(6) | ||
authorId Int | ||
exerciseId Int | ||
userPic String? | ||
flacial marked this conversation as resolved.
Show resolved
Hide resolved
|
||
content String | ||
parentId Int? | ||
exercise Exercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade) | ||
author User @relation(fields: [authorId], references: [id], onDelete: SetNull) | ||
parent Discussion? @relation("DiscussionReplies", fields: [parentId], references: [id]) | ||
replies Discussion[] @relation("DiscussionReplies") | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting userPic to not null, since not every user may have uploaded a profile picture