From 7057b01862aa31303d50de0cdef43f28ef4bddf9 Mon Sep 17 00:00:00 2001 From: Zachary Wen Date: Sun, 19 Jan 2025 11:47:53 -0500 Subject: [PATCH 01/13] #3124: first drafts of schema models --- src/backend/src/prisma/schema.prisma | 53 ++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 12416a4a91..92674b750a 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -230,6 +230,8 @@ model User { deletedTeamTypes Team_Type[] @relation(name: "teamTypeDeleter") unreadAnnouncements Announcement[] @relation(name: "receivedAnnouncements") unreadPopUps PopUp[] @relation(name: "userPopUps") + submissions Submission[] + reviews Review[] } model Role { @@ -444,6 +446,7 @@ model Project { favoritedBy User[] @relation(name: "favoritedBy") featuredByOrganizationId String? featuredByOrganization Organization? @relation(fields: [featuredByOrganizationId], references: [organizationId]) + parts Part[] } model Work_Package { @@ -1052,3 +1055,53 @@ model PopUp { organizationId String organization Organization @relation(fields: [organizationId], references: [organizationId]) } + +model Part { + id String @id @default(uuid()) + index Int + commonName String + description String + status String + tags String[] + submissions Submission[] + reviews Review[] + project Project @relation(fields: [projectId], references: [id]) + projectId Int + assignees User[] @relation("PartAssignees") + reviewers User[] @relation("PartReviewers") + history String[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model Submission { + id String @id @default(uuid()) + files String[] // how do we represent files in the database? + name String + notes String? + part Part @relation(fields: [partId], references: [id]) + partId Int + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model Review { + id String @id @default(uuid()) + files String[] + notes String? + submission Submission @relation(fields: [submissionId], references: [id]) + submissionId Int + part Part @relation(fields: [partId], references: [id]) + partId Int + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model Popup { + id String @id @default(uuid()) + coordinate String + title String + description String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} From d7e6e975526eec81b4a4623743f4cad946f21c2e Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Mon, 20 Jan 2025 10:30:13 -0500 Subject: [PATCH 02/13] #3124 schema changes --- src/backend/src/prisma/schema.prisma | 114 ++++++++++++++++++--------- 1 file changed, 75 insertions(+), 39 deletions(-) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 92674b750a..77ddba1508 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -230,8 +230,14 @@ model User { deletedTeamTypes Team_Type[] @relation(name: "teamTypeDeleter") unreadAnnouncements Announcement[] @relation(name: "receivedAnnouncements") unreadPopUps PopUp[] @relation(name: "userPopUps") - submissions Submission[] - reviews Review[] + createdParts Part[] @relation(name: "partCreator") + deletedParts Part[] @relation(name: "partDeleter") + createdPartSubmissions Submission[] @relation(name: "partsSubmissionCreator") + deletedPartSubmissions Submission[] @relation(name: "partsSubmissionDeleter") + createdPartReviews Review[] @relation(name: "partsReviewCreator") + deletedPartReviews Review[] @relation(name: "partsReviewDeleter") + partsToReview Part[] @relation(name: "PartReviewers") + assignedParts Part[] @relation(name: "PartAssignees") } model Role { @@ -446,6 +452,7 @@ model Project { favoritedBy User[] @relation(name: "favoritedBy") featuredByOrganizationId String? featuredByOrganization Organization? @relation(fields: [featuredByOrganizationId], references: [organizationId]) + abbreviation String parts Part[] } @@ -962,6 +969,7 @@ model Organization { featuredProjects Project[] popUps PopUp[] announcements Announcement[] + parts Part[] } model FrequentlyAskedQuestion { @@ -1057,51 +1065,79 @@ model PopUp { } model Part { - id String @id @default(uuid()) - index Int - commonName String - description String - status String - tags String[] - submissions Submission[] - reviews Review[] - project Project @relation(fields: [projectId], references: [id]) - projectId Int - assignees User[] @relation("PartAssignees") - reviewers User[] @relation("PartReviewers") - history String[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(uuid()) + organizationId String + organization Organization @relation(fields: [organizationId], references: [organizationId]) + index Int + commonName String + description String + status String + tags PartTag[] + submissions Submission[] + reviews Review[] + project Project @relation(fields: [projectId], references: [projectId]) + projectId String + assignees User[] @relation("PartAssignees") + reviewers User[] @relation("PartReviewers") + history String[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userCreatedId String + userCreated User @relation(name: "partCreator", fields: [userCreatedId], references: [userId]) + userDeletedId String + userDeleted User @relation(name: "partDeleter", fields: [userDeletedId], references: [userId]) +} + +model PartTag { + id String @id @default(uuid()) + name String + color String + + parts Part[] } model Submission { - id String @id @default(uuid()) - files String[] // how do we represent files in the database? - name String - notes String? - part Part @relation(fields: [partId], references: [id]) - partId Int - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(uuid()) + files String[] // how do we represent files in the database? + name String + notes String? + part Part @relation(fields: [partId], references: [id]) + partId String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userCreatedId String + userCreated User @relation(name: "partsSubmissionCreator", fields: [userCreatedId], references: [userId]) + userDeletedId String + userDeleted User @relation(name: "partsSubmissionDeleter", fields: [userDeletedId], references: [userId]) + Review Review[] } model Review { - id String @id @default(uuid()) - files String[] - notes String? - submission Submission @relation(fields: [submissionId], references: [id]) - submissionId Int - part Part @relation(fields: [partId], references: [id]) - partId Int - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} - -model Popup { - id String @id @default(uuid()) - coordinate String + id String @id @default(uuid()) + files String[] + notes String? + submission Submission @relation(fields: [submissionId], references: [id]) + submissionId String + part Part @relation(fields: [partId], references: [id]) + partId String + popUps Part_Review_Popup[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + userCreatedId String + userCreated User @relation(name: "partsReviewCreator", fields: [userCreatedId], references: [userId]) + deletedAt DateTime? + userDeletedId String + userDeleted User @relation(name: "partsReviewDeleter", fields: [userDeletedId], references: [userId]) +} + +model Part_Review_Popup { + id String @id @default(uuid()) + xCoord Float + yCoord Float title String description String + reviewId String + review Review @relation(fields: [reviewId], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } From cbc106640ac074671fa679cb99c5b9df2a972a67 Mon Sep 17 00:00:00 2001 From: Griffin Cooper <72273901+gcooper407@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:18:48 -0500 Subject: [PATCH 03/13] #3124: schema tweaks (+ lingering questions) --- src/backend/src/prisma/schema.prisma | 48 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 77ddba1508..a87e543078 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -151,6 +151,14 @@ enum Special_Permission { FINANCE_ONLY } +enum Review_Status { + NA @map("N/A") + READY_FOR_REVIEW @map("Ready for Review") + IN_REVIEW @map("In Review") + REVIEWED @map("Reviewed") + APPROVED @map("Approved") +} + model User { userId String @id @default(uuid()) firstName String @@ -1065,27 +1073,27 @@ model PopUp { } model Part { - id String @id @default(uuid()) + id String @id @default(uuid()) organizationId String - organization Organization @relation(fields: [organizationId], references: [organizationId]) + organization Organization @relation(fields: [organizationId], references: [organizationId]) index Int commonName String - description String - status String + description String? + status Review_Status @default(NA) tags PartTag[] submissions Submission[] - reviews Review[] - project Project @relation(fields: [projectId], references: [projectId]) + reviews Review[] // I feel like Parts don't need reviews field since reviews are linked to submissions, thoughts? + project Project @relation(fields: [projectId], references: [projectId]) projectId String - assignees User[] @relation("PartAssignees") - reviewers User[] @relation("PartReviewers") + assignees User[] @relation("PartAssignees") + reviewers User[] @relation("PartReviewers") history String[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt userCreatedId String - userCreated User @relation(name: "partCreator", fields: [userCreatedId], references: [userId]) - userDeletedId String - userDeleted User @relation(name: "partDeleter", fields: [userDeletedId], references: [userId]) + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") + userDeletedId String? + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partDeleter") } model PartTag { @@ -1106,9 +1114,9 @@ model Submission { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt userCreatedId String - userCreated User @relation(name: "partsSubmissionCreator", fields: [userCreatedId], references: [userId]) - userDeletedId String - userDeleted User @relation(name: "partsSubmissionDeleter", fields: [userDeletedId], references: [userId]) + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsSubmissionCreator") + userDeletedId String? + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsSubmissionDeleter") Review Review[] } @@ -1118,16 +1126,16 @@ model Review { notes String? submission Submission @relation(fields: [submissionId], references: [id]) submissionId String - part Part @relation(fields: [partId], references: [id]) + part Part @relation(fields: [partId], references: [id]) // Also here, do reviews even need to be linked to a part since it's submissions that get reviewed? partId String popUps Part_Review_Popup[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt userCreatedId String - userCreated User @relation(name: "partsReviewCreator", fields: [userCreatedId], references: [userId]) + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsReviewCreator") deletedAt DateTime? - userDeletedId String - userDeleted User @relation(name: "partsReviewDeleter", fields: [userDeletedId], references: [userId]) + userDeletedId String? + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsReviewDeleter") } model Part_Review_Popup { From 88112460b23746c1f239794e61165cbc0a9450b0 Mon Sep 17 00:00:00 2001 From: Griffin Cooper <72273901+gcooper407@users.noreply.github.com> Date: Tue, 21 Jan 2025 18:35:15 -0500 Subject: [PATCH 04/13] #3124: updated schema tweaks (+ lingering questions) --- src/backend/src/prisma/schema.prisma | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index a87e543078..19e0cdd0d7 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -152,11 +152,11 @@ enum Special_Permission { } enum Review_Status { - NA @map("N/A") - READY_FOR_REVIEW @map("Ready for Review") - IN_REVIEW @map("In Review") - REVIEWED @map("Reviewed") - APPROVED @map("Approved") + NA + READY_FOR_REVIEW + IN_REVIEW + REVIEWED + APPROVED } model User { From 6fb5d95119ddd34ff092f7d5c53ea13ef5b9a1bf Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Tue, 21 Jan 2025 20:45:46 -0500 Subject: [PATCH 05/13] #3124 small changes and admin tools --- src/backend/src/prisma/schema.prisma | 68 +++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 19e0cdd0d7..f7cf5cec02 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -246,6 +246,10 @@ model User { deletedPartReviews Review[] @relation(name: "partsReviewDeleter") partsToReview Part[] @relation(name: "PartReviewers") assignedParts Part[] @relation(name: "PartAssignees") + createdPartReviewFAQ PartReviewFAQ[] @relation(name: "partReviewFaqCreator") + deletedPartReviewFAQ PartReviewFAQ[] @relation(name: "partReviewFaqDeleter") + createdCommonMistakes CommonMistake[] @relation(name: "commonMistakeCreator") + deletedCommonMistakes CommonMistake[] @relation(name: "commonMistakeDeleter") } model Role { @@ -978,6 +982,7 @@ model Organization { popUps PopUp[] announcements Announcement[] parts Part[] + Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(name: "partsReviewAdminTools") } model FrequentlyAskedQuestion { @@ -1082,7 +1087,6 @@ model Part { status Review_Status @default(NA) tags PartTag[] submissions Submission[] - reviews Review[] // I feel like Parts don't need reviews field since reviews are linked to submissions, thoughts? project Project @relation(fields: [projectId], references: [projectId]) projectId String assignees User[] @relation("PartAssignees") @@ -1090,6 +1094,7 @@ model Part { history String[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + dateDeleted DateTime? userCreatedId String userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") userDeletedId String? @@ -1101,22 +1106,25 @@ model PartTag { name String color String - parts Part[] + parts Part[] + Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [organizationId], references: [organizationId]) + organizationId String } model Submission { - id String @id @default(uuid()) - files String[] // how do we represent files in the database? + id String @id @default(uuid()) + files String[] name String notes String? - part Part @relation(fields: [partId], references: [id]) + part Part @relation(fields: [partId], references: [id]) partId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + dateDeleted DateTime? userCreatedId String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsSubmissionCreator") + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsSubmissionCreator") userDeletedId String? - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsSubmissionDeleter") + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsSubmissionDeleter") Review Review[] } @@ -1126,11 +1134,10 @@ model Review { notes String? submission Submission @relation(fields: [submissionId], references: [id]) submissionId String - part Part @relation(fields: [partId], references: [id]) // Also here, do reviews even need to be linked to a part since it's submissions that get reviewed? - partId String popUps Part_Review_Popup[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + dateDeleted DateTime? userCreatedId String userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsReviewCreator") deletedAt DateTime? @@ -1149,3 +1156,42 @@ model Part_Review_Popup { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } + +model PartReviewFAQ { + faqId String @id @default(uuid()) + question String + answer String + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partReviewFaqCreator") + userCreatedId String + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partReviewFaqDeleter") + userDeletedId String? + dateCreated DateTime @default(now()) + dateDeleted DateTime? + Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [part_Review_Admin_ToolsOrganizationId], references: [organizationId]) + part_Review_Admin_ToolsOrganizationId String? +} + +model CommonMistake { + id String @id @default(uuid()) + title String + description String + starred Boolean + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "commonMistakeCreator") + userCreatedId String + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "commonMistakeDeleter") + userDeletedId String? + dateCreated DateTime @default(now()) + dateDeleted DateTime? + Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [part_Review_Admin_ToolsOrganizationId], references: [organizationId]) + part_Review_Admin_ToolsOrganizationId String? +} + +model Part_Review_Admin_Tools { + organizationId String @id + organization Organization @relation(name: "partsReviewAdminTools", fields: [organizationId], references: [organizationId]) + sampleDrawingLink String + faq PartReviewFAQ[] + confluenceDrawingGuideLink String + CommonMistakes CommonMistake[] + partTags PartTag[] +} From be27104a57f2a05df3d463fc79d9e97ff8c86119 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 22 Jan 2025 13:59:07 -0500 Subject: [PATCH 06/13] #3124 migration --- .../migration.sql | 235 ++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql diff --git a/src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql b/src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql new file mode 100644 index 0000000000..a21685ce71 --- /dev/null +++ b/src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql @@ -0,0 +1,235 @@ +/* + Warnings: + + - Added the required column `abbreviation` to the `Project` table without a default value. This is not possible if the table is not empty. + +*/ +-- CreateEnum +CREATE TYPE "Review_Status" AS ENUM ('NA', 'READY_FOR_REVIEW', 'IN_REVIEW', 'REVIEWED', 'APPROVED'); + +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT NOT NULL; + +-- CreateTable +CREATE TABLE "Part" ( + "id" TEXT NOT NULL, + "organizationId" TEXT NOT NULL, + "index" INTEGER NOT NULL, + "commonName" TEXT NOT NULL, + "description" TEXT, + "status" "Review_Status" NOT NULL DEFAULT 'NA', + "projectId" TEXT NOT NULL, + "history" TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + + CONSTRAINT "Part_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PartTag" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "color" TEXT NOT NULL, + "organizationId" TEXT NOT NULL, + + CONSTRAINT "PartTag_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Submission" ( + "id" TEXT NOT NULL, + "files" TEXT[], + "name" TEXT NOT NULL, + "notes" TEXT, + "partId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + + CONSTRAINT "Submission_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Review" ( + "id" TEXT NOT NULL, + "files" TEXT[], + "notes" TEXT, + "submissionId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "deletedAt" TIMESTAMP(3), + "userDeletedId" TEXT, + + CONSTRAINT "Review_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Part_Review_Popup" ( + "id" TEXT NOT NULL, + "xCoord" DOUBLE PRECISION NOT NULL, + "yCoord" DOUBLE PRECISION NOT NULL, + "title" TEXT NOT NULL, + "description" TEXT NOT NULL, + "reviewId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "Part_Review_Popup_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PartReviewFAQ" ( + "faqId" TEXT NOT NULL, + "question" TEXT NOT NULL, + "answer" TEXT NOT NULL, + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "dateDeleted" TIMESTAMP(3), + "part_Review_Admin_ToolsOrganizationId" TEXT, + + CONSTRAINT "PartReviewFAQ_pkey" PRIMARY KEY ("faqId") +); + +-- CreateTable +CREATE TABLE "CommonMistake" ( + "id" TEXT NOT NULL, + "title" TEXT NOT NULL, + "description" TEXT NOT NULL, + "starred" BOOLEAN NOT NULL, + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "dateDeleted" TIMESTAMP(3), + "part_Review_Admin_ToolsOrganizationId" TEXT, + + CONSTRAINT "CommonMistake_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Part_Review_Admin_Tools" ( + "organizationId" TEXT NOT NULL, + "sampleDrawingLink" TEXT NOT NULL, + "confluenceDrawingGuideLink" TEXT NOT NULL, + + CONSTRAINT "Part_Review_Admin_Tools_pkey" PRIMARY KEY ("organizationId") +); + +-- CreateTable +CREATE TABLE "_PartToPartTag" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "_PartAssignees" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "_PartReviewers" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "_PartToPartTag_AB_unique" ON "_PartToPartTag"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PartToPartTag_B_index" ON "_PartToPartTag"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_PartAssignees_AB_unique" ON "_PartAssignees"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PartAssignees_B_index" ON "_PartAssignees"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_PartReviewers_AB_unique" ON "_PartReviewers"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PartReviewers_B_index" ON "_PartReviewers"("B"); + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("projectId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartTag" ADD CONSTRAINT "PartTag_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Submission" ADD CONSTRAINT "Submission_partId_fkey" FOREIGN KEY ("partId") REFERENCES "Part"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Review" ADD CONSTRAINT "Review_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "Submission"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Review" ADD CONSTRAINT "Review_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Review" ADD CONSTRAINT "Review_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part_Review_Popup" ADD CONSTRAINT "Part_Review_Popup_reviewId_fkey" FOREIGN KEY ("reviewId") REFERENCES "Review"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_part_Review_Admin_ToolsOrganizationId_fkey" FOREIGN KEY ("part_Review_Admin_ToolsOrganizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_part_Review_Admin_ToolsOrganizationId_fkey" FOREIGN KEY ("part_Review_Admin_ToolsOrganizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part_Review_Admin_Tools" ADD CONSTRAINT "Part_Review_Admin_Tools_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_B_fkey" FOREIGN KEY ("B") REFERENCES "PartTag"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartAssignees" ADD CONSTRAINT "_PartAssignees_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartAssignees" ADD CONSTRAINT "_PartAssignees_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartReviewers" ADD CONSTRAINT "_PartReviewers_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartReviewers" ADD CONSTRAINT "_PartReviewers_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; From 3c3ab0823a0093141e3b754cd30aff8a2ff3bf9e Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 22 Jan 2025 14:04:52 -0500 Subject: [PATCH 07/13] #3124 made abbreviation optional --- src/backend/src/prisma/schema.prisma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index f7cf5cec02..0555bd705a 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -464,7 +464,7 @@ model Project { favoritedBy User[] @relation(name: "favoritedBy") featuredByOrganizationId String? featuredByOrganization Organization? @relation(fields: [featuredByOrganizationId], references: [organizationId]) - abbreviation String + abbreviation String? parts Part[] } From cf20e34daa64c7a70fc67cb7dd5115cb6dfb7170 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 22 Jan 2025 14:27:24 -0500 Subject: [PATCH 08/13] #3124 had to change migration --- .../migration.sql | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) rename src/backend/src/prisma/migrations/{20250122184808_cad_project_file_reviews => 20250122192508_cad_project_file_reviews}/migration.sql (97%) diff --git a/src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql b/src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql similarity index 97% rename from src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql rename to src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql index a21685ce71..b5e8d80f6f 100644 --- a/src/backend/src/prisma/migrations/20250122184808_cad_project_file_reviews/migration.sql +++ b/src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql @@ -1,14 +1,8 @@ -/* - Warnings: - - - Added the required column `abbreviation` to the `Project` table without a default value. This is not possible if the table is not empty. - -*/ -- CreateEnum CREATE TYPE "Review_Status" AS ENUM ('NA', 'READY_FOR_REVIEW', 'IN_REVIEW', 'REVIEWED', 'APPROVED'); -- AlterTable -ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT NOT NULL; +ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT; -- CreateTable CREATE TABLE "Part" ( From 20b35e8a46a376599e6b458ba6a8e941c6d95003 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 22 Jan 2025 16:08:35 -0500 Subject: [PATCH 09/13] #3124 added option preview image to parts --- .../migration.sql | 1 + src/backend/src/prisma/schema.prisma | 43 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) rename src/backend/src/prisma/migrations/{20250122192508_cad_project_file_reviews => 20250122210746_cad_project_file_review}/migration.sql (99%) diff --git a/src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql b/src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql similarity index 99% rename from src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql rename to src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql index b5e8d80f6f..3977aa8306 100644 --- a/src/backend/src/prisma/migrations/20250122192508_cad_project_file_reviews/migration.sql +++ b/src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql @@ -11,6 +11,7 @@ CREATE TABLE "Part" ( "index" INTEGER NOT NULL, "commonName" TEXT NOT NULL, "description" TEXT, + "previewImageLink" TEXT, "status" "Review_Status" NOT NULL DEFAULT 'NA', "projectId" TEXT NOT NULL, "history" TEXT[], diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 3842bf772d..3712a65339 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -1125,27 +1125,28 @@ model Contact { } model Part { - id String @id @default(uuid()) - organizationId String - organization Organization @relation(fields: [organizationId], references: [organizationId]) - index Int - commonName String - description String? - status Review_Status @default(NA) - tags PartTag[] - submissions Submission[] - project Project @relation(fields: [projectId], references: [projectId]) - projectId String - assignees User[] @relation("PartAssignees") - reviewers User[] @relation("PartReviewers") - history String[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - dateDeleted DateTime? - userCreatedId String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") - userDeletedId String? - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partDeleter") + id String @id @default(uuid()) + organizationId String + organization Organization @relation(fields: [organizationId], references: [organizationId]) + index Int + commonName String + description String? + previewImageLink String? + status Review_Status @default(NA) + tags PartTag[] + submissions Submission[] + project Project @relation(fields: [projectId], references: [projectId]) + projectId String + assignees User[] @relation("PartAssignees") + reviewers User[] @relation("PartReviewers") + history String[] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + dateDeleted DateTime? + userCreatedId String + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") + userDeletedId String? + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partDeleter") } model PartTag { From 5ab81542ee4b22a3f38b85da605518795385d4f4 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 22 Jan 2025 22:07:53 -0500 Subject: [PATCH 10/13] #3124 added skelaton express route --- src/backend/index.ts | 2 ++ src/backend/src/routes/parts.routes.ts | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 src/backend/src/routes/parts.routes.ts diff --git a/src/backend/index.ts b/src/backend/index.ts index 6caa2f24ec..26778cee1f 100644 --- a/src/backend/index.ts +++ b/src/backend/index.ts @@ -22,6 +22,7 @@ import announcementsRouter from './src/routes/announcements.routes'; import onboardingRouter from './src/routes/onboarding.routes'; import popUpsRouter from './src/routes/pop-up.routes'; import statisticsRouter from './src/routes/statistics.routes'; +import partsRouter from './src/routes/parts.routes'; const app = express(); @@ -81,6 +82,7 @@ app.use('/pop-ups', popUpsRouter); app.use('/announcements', announcementsRouter); app.use('/onboarding', onboardingRouter); app.use('/statistics', statisticsRouter); +app.use('/parts', partsRouter); app.use('/', (_req, res) => { res.status(200).json('Welcome to FinishLine'); }); diff --git a/src/backend/src/routes/parts.routes.ts b/src/backend/src/routes/parts.routes.ts new file mode 100644 index 0000000000..7d8ea0ecda --- /dev/null +++ b/src/backend/src/routes/parts.routes.ts @@ -0,0 +1,5 @@ +import express from 'express'; + +const partsRouter = express.Router(); + +export default partsRouter; From 3071a3f70107f36718fc2512fe27eb86e1dd14f7 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Thu, 23 Jan 2025 23:15:41 -0500 Subject: [PATCH 11/13] #3124 combined FAQs, moved admin tools to org, various changes --- .../migration.sql | 230 ------------------ .../migration.sql | 224 +++++++++++++++++ src/backend/src/prisma/schema.prisma | 225 ++++++++--------- .../src/services/recruitment.services.ts | 4 +- src/backend/tests/test-utils.ts | 4 +- 5 files changed, 331 insertions(+), 356 deletions(-) delete mode 100644 src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql create mode 100644 src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql diff --git a/src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql b/src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql deleted file mode 100644 index 3977aa8306..0000000000 --- a/src/backend/src/prisma/migrations/20250122210746_cad_project_file_review/migration.sql +++ /dev/null @@ -1,230 +0,0 @@ --- CreateEnum -CREATE TYPE "Review_Status" AS ENUM ('NA', 'READY_FOR_REVIEW', 'IN_REVIEW', 'REVIEWED', 'APPROVED'); - --- AlterTable -ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT; - --- CreateTable -CREATE TABLE "Part" ( - "id" TEXT NOT NULL, - "organizationId" TEXT NOT NULL, - "index" INTEGER NOT NULL, - "commonName" TEXT NOT NULL, - "description" TEXT, - "previewImageLink" TEXT, - "status" "Review_Status" NOT NULL DEFAULT 'NA', - "projectId" TEXT NOT NULL, - "history" TEXT[], - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "dateDeleted" TIMESTAMP(3), - "userCreatedId" TEXT NOT NULL, - "userDeletedId" TEXT, - - CONSTRAINT "Part_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PartTag" ( - "id" TEXT NOT NULL, - "name" TEXT NOT NULL, - "color" TEXT NOT NULL, - "organizationId" TEXT NOT NULL, - - CONSTRAINT "PartTag_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Submission" ( - "id" TEXT NOT NULL, - "files" TEXT[], - "name" TEXT NOT NULL, - "notes" TEXT, - "partId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "dateDeleted" TIMESTAMP(3), - "userCreatedId" TEXT NOT NULL, - "userDeletedId" TEXT, - - CONSTRAINT "Submission_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Review" ( - "id" TEXT NOT NULL, - "files" TEXT[], - "notes" TEXT, - "submissionId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - "dateDeleted" TIMESTAMP(3), - "userCreatedId" TEXT NOT NULL, - "deletedAt" TIMESTAMP(3), - "userDeletedId" TEXT, - - CONSTRAINT "Review_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Part_Review_Popup" ( - "id" TEXT NOT NULL, - "xCoord" DOUBLE PRECISION NOT NULL, - "yCoord" DOUBLE PRECISION NOT NULL, - "title" TEXT NOT NULL, - "description" TEXT NOT NULL, - "reviewId" TEXT NOT NULL, - "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" TIMESTAMP(3) NOT NULL, - - CONSTRAINT "Part_Review_Popup_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "PartReviewFAQ" ( - "faqId" TEXT NOT NULL, - "question" TEXT NOT NULL, - "answer" TEXT NOT NULL, - "userCreatedId" TEXT NOT NULL, - "userDeletedId" TEXT, - "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "dateDeleted" TIMESTAMP(3), - "part_Review_Admin_ToolsOrganizationId" TEXT, - - CONSTRAINT "PartReviewFAQ_pkey" PRIMARY KEY ("faqId") -); - --- CreateTable -CREATE TABLE "CommonMistake" ( - "id" TEXT NOT NULL, - "title" TEXT NOT NULL, - "description" TEXT NOT NULL, - "starred" BOOLEAN NOT NULL, - "userCreatedId" TEXT NOT NULL, - "userDeletedId" TEXT, - "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "dateDeleted" TIMESTAMP(3), - "part_Review_Admin_ToolsOrganizationId" TEXT, - - CONSTRAINT "CommonMistake_pkey" PRIMARY KEY ("id") -); - --- CreateTable -CREATE TABLE "Part_Review_Admin_Tools" ( - "organizationId" TEXT NOT NULL, - "sampleDrawingLink" TEXT NOT NULL, - "confluenceDrawingGuideLink" TEXT NOT NULL, - - CONSTRAINT "Part_Review_Admin_Tools_pkey" PRIMARY KEY ("organizationId") -); - --- CreateTable -CREATE TABLE "_PartToPartTag" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL -); - --- CreateTable -CREATE TABLE "_PartAssignees" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL -); - --- CreateTable -CREATE TABLE "_PartReviewers" ( - "A" TEXT NOT NULL, - "B" TEXT NOT NULL -); - --- CreateIndex -CREATE UNIQUE INDEX "_PartToPartTag_AB_unique" ON "_PartToPartTag"("A", "B"); - --- CreateIndex -CREATE INDEX "_PartToPartTag_B_index" ON "_PartToPartTag"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_PartAssignees_AB_unique" ON "_PartAssignees"("A", "B"); - --- CreateIndex -CREATE INDEX "_PartAssignees_B_index" ON "_PartAssignees"("B"); - --- CreateIndex -CREATE UNIQUE INDEX "_PartReviewers_AB_unique" ON "_PartReviewers"("A", "B"); - --- CreateIndex -CREATE INDEX "_PartReviewers_B_index" ON "_PartReviewers"("B"); - --- AddForeignKey -ALTER TABLE "Part" ADD CONSTRAINT "Part_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Part" ADD CONSTRAINT "Part_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("projectId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Part" ADD CONSTRAINT "Part_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Part" ADD CONSTRAINT "Part_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PartTag" ADD CONSTRAINT "PartTag_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Submission" ADD CONSTRAINT "Submission_partId_fkey" FOREIGN KEY ("partId") REFERENCES "Part"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Review" ADD CONSTRAINT "Review_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "Submission"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Review" ADD CONSTRAINT "Review_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Review" ADD CONSTRAINT "Review_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Part_Review_Popup" ADD CONSTRAINT "Part_Review_Popup_reviewId_fkey" FOREIGN KEY ("reviewId") REFERENCES "Review"("id") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "PartReviewFAQ" ADD CONSTRAINT "PartReviewFAQ_part_Review_Admin_ToolsOrganizationId_fkey" FOREIGN KEY ("part_Review_Admin_ToolsOrganizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "CommonMistake" ADD CONSTRAINT "CommonMistake_part_Review_Admin_ToolsOrganizationId_fkey" FOREIGN KEY ("part_Review_Admin_ToolsOrganizationId") REFERENCES "Part_Review_Admin_Tools"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "Part_Review_Admin_Tools" ADD CONSTRAINT "Part_Review_Admin_Tools_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_B_fkey" FOREIGN KEY ("B") REFERENCES "PartTag"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartAssignees" ADD CONSTRAINT "_PartAssignees_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartAssignees" ADD CONSTRAINT "_PartAssignees_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartReviewers" ADD CONSTRAINT "_PartReviewers_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("id") ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "_PartReviewers" ADD CONSTRAINT "_PartReviewers_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql b/src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql new file mode 100644 index 0000000000..9574dc8887 --- /dev/null +++ b/src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql @@ -0,0 +1,224 @@ +/* + Warnings: + + - You are about to drop the column `organizationId` on the `FrequentlyAskedQuestion` table. All the data in the column will be lost. + +*/ +-- CreateEnum +CREATE TYPE "Review_Status" AS ENUM ('IN_PROGRESS', 'READY_FOR_REVIEW', 'IN_REVIEW', 'REVIEWED', 'APPROVED'); + +-- DropForeignKey +ALTER TABLE "FrequentlyAskedQuestion" DROP CONSTRAINT "FrequentlyAskedQuestion_organizationId_fkey"; + +-- AlterTable +ALTER TABLE "FrequentlyAskedQuestion" DROP COLUMN "organizationId", +ADD COLUMN "partReviewFaqOrgId" TEXT, +ADD COLUMN "regularFaqOrgId" TEXT; + +-- AlterTable +ALTER TABLE "Organization" ADD COLUMN "partReviewSampleImageId" TEXT; + +-- AlterTable +ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT; + +-- CreateTable +CREATE TABLE "Part" ( + "partId" TEXT NOT NULL, + "organizationId" TEXT NOT NULL, + "index" INTEGER NOT NULL, + "commonName" TEXT NOT NULL, + "description" TEXT, + "previewImageLink" TEXT, + "status" "Review_Status" NOT NULL DEFAULT 'IN_PROGRESS', + "projectId" TEXT NOT NULL, + "history" TEXT[], + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + + CONSTRAINT "Part_pkey" PRIMARY KEY ("partId") +); + +-- CreateTable +CREATE TABLE "PartTag" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "color" TEXT NOT NULL, + "dateCreated" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "OrganizationId" TEXT, + + CONSTRAINT "PartTag_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PartSubmission" ( + "id" TEXT NOT NULL, + "fileIds" TEXT[], + "name" TEXT NOT NULL, + "notes" TEXT, + "partId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + + CONSTRAINT "PartSubmission_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "PartReview" ( + "partReviewId" TEXT NOT NULL, + "fileIds" TEXT[], + "notes" TEXT, + "submissionId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "dateDeleted" TIMESTAMP(3), + "userCreatedId" TEXT NOT NULL, + "deletedAt" TIMESTAMP(3), + "userDeletedId" TEXT, + + CONSTRAINT "PartReview_pkey" PRIMARY KEY ("partReviewId") +); + +-- CreateTable +CREATE TABLE "Part_Review_Popup" ( + "partReviewPopupId" TEXT NOT NULL, + "xCoord" DOUBLE PRECISION NOT NULL, + "yCoord" DOUBLE PRECISION NOT NULL, + "title" TEXT NOT NULL, + "description" TEXT NOT NULL, + "reviewId" TEXT NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + "deletedAd" TIMESTAMP(3), + + CONSTRAINT "Part_Review_Popup_pkey" PRIMARY KEY ("partReviewPopupId") +); + +-- CreateTable +CREATE TABLE "PartReviewCommonMistake" ( + "id" TEXT NOT NULL, + "title" TEXT NOT NULL, + "description" TEXT NOT NULL, + "starred" BOOLEAN NOT NULL, + "userCreatedId" TEXT NOT NULL, + "userDeletedId" TEXT, + "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "dateDeleted" TIMESTAMP(3), + "OrganizationId" TEXT, + + CONSTRAINT "PartReviewCommonMistake_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "_PartToPartTag" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "_partAssignees" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateTable +CREATE TABLE "_partReviewers" ( + "A" TEXT NOT NULL, + "B" TEXT NOT NULL +); + +-- CreateIndex +CREATE UNIQUE INDEX "_PartToPartTag_AB_unique" ON "_PartToPartTag"("A", "B"); + +-- CreateIndex +CREATE INDEX "_PartToPartTag_B_index" ON "_PartToPartTag"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_partAssignees_AB_unique" ON "_partAssignees"("A", "B"); + +-- CreateIndex +CREATE INDEX "_partAssignees_B_index" ON "_partAssignees"("B"); + +-- CreateIndex +CREATE UNIQUE INDEX "_partReviewers_AB_unique" ON "_partReviewers"("A", "B"); + +-- CreateIndex +CREATE INDEX "_partReviewers_B_index" ON "_partReviewers"("B"); + +-- AddForeignKey +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_regularFaqOrgId_fkey" FOREIGN KEY ("regularFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_partReviewFaqOrgId_fkey" FOREIGN KEY ("partReviewFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- Add Constraint so FAQs must have either a regularFaqOrg or a partReviewFaqOrg +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "at_least_one_field_required" CHECK ("regularFaqOrgId" IS NOT NULL OR "partReviewFaqOrgId" IS NOT NULL); + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("projectId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part" ADD CONSTRAINT "Part_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartTag" ADD CONSTRAINT "PartTag_OrganizationId_fkey" FOREIGN KEY ("OrganizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartSubmission" ADD CONSTRAINT "PartSubmission_partId_fkey" FOREIGN KEY ("partId") REFERENCES "Part"("partId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartSubmission" ADD CONSTRAINT "PartSubmission_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartSubmission" ADD CONSTRAINT "PartSubmission_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReview" ADD CONSTRAINT "PartReview_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "PartSubmission"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReview" ADD CONSTRAINT "PartReview_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReview" ADD CONSTRAINT "PartReview_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Part_Review_Popup" ADD CONSTRAINT "Part_Review_Popup_reviewId_fkey" FOREIGN KEY ("reviewId") REFERENCES "PartReview"("partReviewId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_OrganizationId_fkey" FOREIGN KEY ("OrganizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("partId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_B_fkey" FOREIGN KEY ("B") REFERENCES "PartTag"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_partAssignees" ADD CONSTRAINT "_partAssignees_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("partId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_partAssignees" ADD CONSTRAINT "_partAssignees_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_partReviewers" ADD CONSTRAINT "_partReviewers_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("partId") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "_partReviewers" ADD CONSTRAINT "_partReviewers_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 3712a65339..89a8f7dea4 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -152,7 +152,7 @@ enum Special_Permission { } enum Review_Status { - NA + IN_PROGRESS READY_FOR_REVIEW IN_REVIEW REVIEWED @@ -246,16 +246,14 @@ model User { onboardedTeamTypes Team_Type[] @relation(name: "onboardedTeamTypes") createdParts Part[] @relation(name: "partCreator") deletedParts Part[] @relation(name: "partDeleter") - createdPartSubmissions Submission[] @relation(name: "partsSubmissionCreator") - deletedPartSubmissions Submission[] @relation(name: "partsSubmissionDeleter") - createdPartReviews Review[] @relation(name: "partsReviewCreator") - deletedPartReviews Review[] @relation(name: "partsReviewDeleter") - partsToReview Part[] @relation(name: "PartReviewers") - assignedParts Part[] @relation(name: "PartAssignees") - createdPartReviewFAQ PartReviewFAQ[] @relation(name: "partReviewFaqCreator") - deletedPartReviewFAQ PartReviewFAQ[] @relation(name: "partReviewFaqDeleter") - createdCommonMistakes CommonMistake[] @relation(name: "commonMistakeCreator") - deletedCommonMistakes CommonMistake[] @relation(name: "commonMistakeDeleter") + createdPartSubmissions PartSubmission[] @relation(name: "partsSubmissionCreator") + deletedPartSubmissions PartSubmission[] @relation(name: "partsSubmissionDeleter") + createdPartReviews PartReview[] @relation(name: "partsReviewCreator") + deletedPartReviews PartReview[] @relation(name: "partsReviewDeleter") + partsToReview Part[] @relation(name: "partReviewers") + assignedParts Part[] @relation(name: "partAssignees") + createdCommonMistakes PartReviewCommonMistake[] @relation(name: "commonMistakeCreator") + deletedCommonMistakes PartReviewCommonMistake[] @relation(name: "commonMistakeDeleter") } model Role { @@ -947,25 +945,26 @@ model Car { } model Organization { - organizationId String @id @default(uuid()) - name String - dateCreated DateTime @default(now()) - userCreatedId String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "organizationCreator") - dateDeleted DateTime? - userDeletedId String? - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "organizationDeleter") - treasurerId String? - treasurer User? @relation(name: "treasurer", fields: [treasurerId], references: [userId]) - advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId]) - advisorId String? - description String @default("") - applyInterestImageId String? - exploreAsGuestImageId String? - logoImageId String? - slackWorkspaceId String? - applicationLink String? - onboardingText String? + organizationId String @id @default(uuid()) + name String + dateCreated DateTime @default(now()) + userCreatedId String + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "organizationCreator") + dateDeleted DateTime? + userDeletedId String? + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "organizationDeleter") + treasurerId String? + treasurer User? @relation(name: "treasurer", fields: [treasurerId], references: [userId]) + advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId]) + advisorId String? + description String @default("") + applyInterestImageId String? + exploreAsGuestImageId String? + logoImageId String? + slackWorkspaceId String? + applicationLink String? + onboardingText String? + partReviewSampleImageId String? // Relation references wbsElements WBS_Element[] @@ -985,7 +984,8 @@ model Organization { changeRequests Change_Request[] reimbursementReqeusts Reimbursement_Request[] usefulLinks Link[] - frequentlyAskedQuestions FrequentlyAskedQuestion[] + frequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "regularFaq") + partReviewFAQ FrequentlyAskedQuestion[] milestones Milestone[] graphCollections Graph_Collection[] graphs Graph[] @@ -995,21 +995,24 @@ model Organization { checklists Checklist[] contacts Contact[] parts Part[] - Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(name: "partsReviewAdminTools") + partReviewCommonMistakes PartReviewCommonMistake[] + partTags PartTag[] } model FrequentlyAskedQuestion { - faqId String @id @default(uuid()) - question String - answer String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "frequentlyAskedQuestionCreator") - userCreatedId String - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "frequentlyAskedQuestionDeleter") - userDeletedId String? - dateCreated DateTime @default(now()) - dateDeleted DateTime? - organizationId String - organization Organization @relation(fields: [organizationId], references: [organizationId]) + faqId String @id @default(uuid()) + question String + answer String + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "frequentlyAskedQuestionCreator") + userCreatedId String + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "frequentlyAskedQuestionDeleter") + userDeletedId String? + dateCreated DateTime @default(now()) + dateDeleted DateTime? + regularFaqOrgId String? + regularFaqOrg Organization? @relation(fields: [regularFaqOrgId], references: [organizationId], name: "regularFaq") + partReviewFaqOrgId String? + partReviewFaqOrg Organization? @relation(fields: [partReviewFaqOrgId], references: [organizationId]) } model Milestone { @@ -1125,62 +1128,63 @@ model Contact { } model Part { - id String @id @default(uuid()) + partId String @id @default(uuid()) organizationId String - organization Organization @relation(fields: [organizationId], references: [organizationId]) + organization Organization @relation(fields: [organizationId], references: [organizationId]) index Int commonName String description String? previewImageLink String? - status Review_Status @default(NA) + status Review_Status @default(IN_PROGRESS) tags PartTag[] - submissions Submission[] - project Project @relation(fields: [projectId], references: [projectId]) + submissions PartSubmission[] + project Project @relation(fields: [projectId], references: [projectId]) projectId String - assignees User[] @relation("PartAssignees") - reviewers User[] @relation("PartReviewers") + assignees User[] @relation("partAssignees") + reviewers User[] @relation("partReviewers") history String[] - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt dateDeleted DateTime? userCreatedId String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partCreator") userDeletedId String? - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partDeleter") + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partDeleter") } model PartTag { - id String @id @default(uuid()) - name String - color String - - parts Part[] - Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [organizationId], references: [organizationId]) - organizationId String + id String @id @default(uuid()) + name String + color String + dateCreated DateTime + dateDeleted DateTime? + parts Part[] + Organization Organization? @relation(fields: [OrganizationId], references: [organizationId]) + OrganizationId String? } -model Submission { - id String @id @default(uuid()) - files String[] +model PartSubmission { + id String @id @default(uuid()) + fileIds String[] name String notes String? - part Part @relation(fields: [partId], references: [id]) + part Part @relation(fields: [partId], references: [partId]) partId String - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt dateDeleted DateTime? userCreatedId String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsSubmissionCreator") + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partsSubmissionCreator") userDeletedId String? - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsSubmissionDeleter") - Review Review[] + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partsSubmissionDeleter") + reviews PartReview[] } -model Review { - id String @id @default(uuid()) - files String[] +model PartReview { + partReviewId String @id @default(uuid()) + fileIds String[] notes String? - submission Submission @relation(fields: [submissionId], references: [id]) + submission PartSubmission @relation(fields: [submissionId], references: [id]) submissionId String popUps Part_Review_Popup[] createdAt DateTime @default(now()) @@ -1194,52 +1198,29 @@ model Review { } model Part_Review_Popup { - id String @id @default(uuid()) - xCoord Float - yCoord Float - title String - description String - reviewId String - review Review @relation(fields: [reviewId], references: [id]) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt -} - -model PartReviewFAQ { - faqId String @id @default(uuid()) - question String - answer String - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "partReviewFaqCreator") - userCreatedId String - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "partReviewFaqDeleter") - userDeletedId String? - dateCreated DateTime @default(now()) - dateDeleted DateTime? - Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [part_Review_Admin_ToolsOrganizationId], references: [organizationId]) - part_Review_Admin_ToolsOrganizationId String? -} - -model CommonMistake { - id String @id @default(uuid()) - title String - description String - starred Boolean - userCreated User @relation(fields: [userCreatedId], references: [userId], name: "commonMistakeCreator") - userCreatedId String - userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "commonMistakeDeleter") - userDeletedId String? - dateCreated DateTime @default(now()) - dateDeleted DateTime? - Part_Review_Admin_Tools Part_Review_Admin_Tools? @relation(fields: [part_Review_Admin_ToolsOrganizationId], references: [organizationId]) - part_Review_Admin_ToolsOrganizationId String? -} - -model Part_Review_Admin_Tools { - organizationId String @id - organization Organization @relation(name: "partsReviewAdminTools", fields: [organizationId], references: [organizationId]) - sampleDrawingLink String - faq PartReviewFAQ[] - confluenceDrawingGuideLink String - CommonMistakes CommonMistake[] - partTags PartTag[] + partReviewPopupId String @id @default(uuid()) + xCoord Float + yCoord Float + title String + description String + reviewId String + review PartReview @relation(fields: [reviewId], references: [partReviewId]) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + deletedAd DateTime? +} + +model PartReviewCommonMistake { + id String @id @default(uuid()) + title String + description String + starred Boolean + userCreated User @relation(fields: [userCreatedId], references: [userId], name: "commonMistakeCreator") + userCreatedId String + userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "commonMistakeDeleter") + userDeletedId String? + dateCreated DateTime @default(now()) + dateDeleted DateTime? + Organization Organization? @relation(fields: [OrganizationId], references: [organizationId]) + OrganizationId String? } diff --git a/src/backend/src/services/recruitment.services.ts b/src/backend/src/services/recruitment.services.ts index 39b1ecae13..089e0c1c4b 100644 --- a/src/backend/src/services/recruitment.services.ts +++ b/src/backend/src/services/recruitment.services.ts @@ -106,7 +106,7 @@ export default class RecruitmentServices { */ static async getAllFaqs(organization: Organization) { const allFaqs = await prisma.frequentlyAskedQuestion.findMany({ - where: { dateDeleted: null, organizationId: organization.organizationId } + where: { dateDeleted: null, regularFaqOrgId: organization.organizationId } }); return allFaqs; @@ -150,7 +150,7 @@ export default class RecruitmentServices { data: { question, answer, - organizationId: organization.organizationId, + regularFaqOrgId: organization.organizationId, userCreatedId: submitter.userId } }); diff --git a/src/backend/tests/test-utils.ts b/src/backend/tests/test-utils.ts index 22b95f89d5..d853a89da5 100644 --- a/src/backend/tests/test-utils.ts +++ b/src/backend/tests/test-utils.ts @@ -198,7 +198,7 @@ export const createTestFAQ = async (orgId: string, faqId: string) => { userId: user.userId } }, - organization: { + regularFaqOrg: { connect: { organizationId: orgId } @@ -258,7 +258,7 @@ export const createTestFaq = async (user: User, organizationId: string) => { data: { question: 'Who is Chief Software Engineer of NER?', answer: 'Peyton McKee!', - organizationId, + regularFaqOrgId: organizationId, userCreatedId: user.userId } }); From 74ccba9dcc2bfd6e9d92839f23ed74f28fbc7e90 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Fri, 24 Jan 2025 18:53:36 -0500 Subject: [PATCH 12/13] #3124 minor changes, naming fixes, and migration changes --- .../controllers/recruitment.controllers.ts | 8 ++-- .../migration.sql | 40 +++++++------------ src/backend/src/prisma/schema.prisma | 19 ++++----- src/backend/src/prisma/seed.ts | 16 ++++++-- src/backend/src/routes/recruitment.routes.ts | 4 +- .../src/services/recruitment.services.ts | 4 +- 6 files changed, 43 insertions(+), 48 deletions(-) rename src/backend/src/prisma/migrations/{20250124040302_cad_part_file_review => 20250124235046_cad_part_file_review}/migration.sql (89%) diff --git a/src/backend/src/controllers/recruitment.controllers.ts b/src/backend/src/controllers/recruitment.controllers.ts index 3dfdc0eeeb..8bf4f90130 100644 --- a/src/backend/src/controllers/recruitment.controllers.ts +++ b/src/backend/src/controllers/recruitment.controllers.ts @@ -57,19 +57,19 @@ export default class RecruitmentController { } } - static async getAllFaqs(req: Request, res: Response, next: NextFunction) { + static async getAllOrganizationFaqs(req: Request, res: Response, next: NextFunction) { try { - const allFaqs = await RecruitmentServices.getAllFaqs(req.organization); + const allFaqs = await RecruitmentServices.getAllOrganizationFaqs(req.organization); res.status(200).json(allFaqs); } catch (error: unknown) { next(error); } } - static async createFaq(req: Request, res: Response, next: NextFunction) { + static async createOrganizationFaq(req: Request, res: Response, next: NextFunction) { try { const { question, answer } = req.body; - const faq = await RecruitmentServices.createFaq(req.currentUser, question, answer, req.organization); + const faq = await RecruitmentServices.createOrganizationFaq(req.currentUser, question, answer, req.organization); res.status(200).json(faq); } catch (error: unknown) { next(error); diff --git a/src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql b/src/backend/src/prisma/migrations/20250124235046_cad_part_file_review/migration.sql similarity index 89% rename from src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql rename to src/backend/src/prisma/migrations/20250124235046_cad_part_file_review/migration.sql index 9574dc8887..1b0c29f897 100644 --- a/src/backend/src/prisma/migrations/20250124040302_cad_part_file_review/migration.sql +++ b/src/backend/src/prisma/migrations/20250124235046_cad_part_file_review/migration.sql @@ -9,11 +9,12 @@ CREATE TYPE "Review_Status" AS ENUM ('IN_PROGRESS', 'READY_FOR_REVIEW', 'IN_REVI -- DropForeignKey ALTER TABLE "FrequentlyAskedQuestion" DROP CONSTRAINT "FrequentlyAskedQuestion_organizationId_fkey"; - --- AlterTable -ALTER TABLE "FrequentlyAskedQuestion" DROP COLUMN "organizationId", -ADD COLUMN "partReviewFaqOrgId" TEXT, -ADD COLUMN "regularFaqOrgId" TEXT; +ALTER TABLE "FrequentlyAskedQuestion" RENAME COLUMN "organizationId" TO "regularFaqOrgId"; +ALTER TABLE "FrequentlyAskedQuestion" ADD COLUMN "partReviewFaqOrgId" TEXT; +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_regularFaqOrgId_fkey" FOREIGN KEY ("regularFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_partReviewFaqOrgId_fkey" FOREIGN KEY ("partReviewFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; +-- Add constriant so every faq is either a reulage faq or a part review faq +ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "at_least_one_field_required" CHECK ("regularFaqOrgId" IS NOT NULL OR "partReviewFaqOrgId" IS NOT NULL); -- AlterTable ALTER TABLE "Organization" ADD COLUMN "partReviewSampleImageId" TEXT; @@ -24,7 +25,6 @@ ALTER TABLE "Project" ADD COLUMN "abbreviation" TEXT; -- CreateTable CREATE TABLE "Part" ( "partId" TEXT NOT NULL, - "organizationId" TEXT NOT NULL, "index" INTEGER NOT NULL, "commonName" TEXT NOT NULL, "description" TEXT, @@ -43,14 +43,14 @@ CREATE TABLE "Part" ( -- CreateTable CREATE TABLE "PartTag" ( - "id" TEXT NOT NULL, + "partTagId" TEXT NOT NULL, "name" TEXT NOT NULL, - "color" TEXT NOT NULL, + "colorHexCode" TEXT NOT NULL, "dateCreated" TIMESTAMP(3) NOT NULL, "dateDeleted" TIMESTAMP(3), - "OrganizationId" TEXT, + "organizationId" TEXT, - CONSTRAINT "PartTag_pkey" PRIMARY KEY ("id") + CONSTRAINT "PartTag_pkey" PRIMARY KEY ("partTagId") ); -- CreateTable @@ -110,7 +110,7 @@ CREATE TABLE "PartReviewCommonMistake" ( "userDeletedId" TEXT, "dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "dateDeleted" TIMESTAMP(3), - "OrganizationId" TEXT, + "organizationId" TEXT, CONSTRAINT "PartReviewCommonMistake_pkey" PRIMARY KEY ("id") ); @@ -151,18 +151,6 @@ CREATE UNIQUE INDEX "_partReviewers_AB_unique" ON "_partReviewers"("A", "B"); -- CreateIndex CREATE INDEX "_partReviewers_B_index" ON "_partReviewers"("B"); --- AddForeignKey -ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_regularFaqOrgId_fkey" FOREIGN KEY ("regularFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_partReviewFaqOrgId_fkey" FOREIGN KEY ("partReviewFaqOrgId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; - --- Add Constraint so FAQs must have either a regularFaqOrg or a partReviewFaqOrg -ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "at_least_one_field_required" CHECK ("regularFaqOrgId" IS NOT NULL OR "partReviewFaqOrgId" IS NOT NULL); - --- AddForeignKey -ALTER TABLE "Part" ADD CONSTRAINT "Part_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE; - -- AddForeignKey ALTER TABLE "Part" ADD CONSTRAINT "Part_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("projectId") ON DELETE RESTRICT ON UPDATE CASCADE; @@ -173,7 +161,7 @@ ALTER TABLE "Part" ADD CONSTRAINT "Part_userCreatedId_fkey" FOREIGN KEY ("userCr ALTER TABLE "Part" ADD CONSTRAINT "Part_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "PartTag" ADD CONSTRAINT "PartTag_OrganizationId_fkey" FOREIGN KEY ("OrganizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "PartTag" ADD CONSTRAINT "PartTag_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "PartSubmission" ADD CONSTRAINT "PartSubmission_partId_fkey" FOREIGN KEY ("partId") REFERENCES "Part"("partId") ON DELETE RESTRICT ON UPDATE CASCADE; @@ -203,13 +191,13 @@ ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_us ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_OrganizationId_fkey" FOREIGN KEY ("OrganizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "PartReviewCommonMistake" ADD CONSTRAINT "PartReviewCommonMistake_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("partId") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_B_fkey" FOREIGN KEY ("B") REFERENCES "PartTag"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "_PartToPartTag" ADD CONSTRAINT "_PartToPartTag_B_fkey" FOREIGN KEY ("B") REFERENCES "PartTag"("partTagId") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "_partAssignees" ADD CONSTRAINT "_partAssignees_A_fkey" FOREIGN KEY ("A") REFERENCES "Part"("partId") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/backend/src/prisma/schema.prisma b/src/backend/src/prisma/schema.prisma index 89a8f7dea4..3d679e977e 100644 --- a/src/backend/src/prisma/schema.prisma +++ b/src/backend/src/prisma/schema.prisma @@ -984,7 +984,7 @@ model Organization { changeRequests Change_Request[] reimbursementReqeusts Reimbursement_Request[] usefulLinks Link[] - frequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "regularFaq") + frequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "organizationFAQ") partReviewFAQ FrequentlyAskedQuestion[] milestones Milestone[] graphCollections Graph_Collection[] @@ -994,7 +994,6 @@ model Organization { announcements Announcement[] checklists Checklist[] contacts Contact[] - parts Part[] partReviewCommonMistakes PartReviewCommonMistake[] partTags PartTag[] } @@ -1010,7 +1009,7 @@ model FrequentlyAskedQuestion { dateCreated DateTime @default(now()) dateDeleted DateTime? regularFaqOrgId String? - regularFaqOrg Organization? @relation(fields: [regularFaqOrgId], references: [organizationId], name: "regularFaq") + regularFaqOrg Organization? @relation(fields: [regularFaqOrgId], references: [organizationId], name: "organizationFAQ") partReviewFaqOrgId String? partReviewFaqOrg Organization? @relation(fields: [partReviewFaqOrgId], references: [organizationId]) } @@ -1129,8 +1128,6 @@ model Contact { model Part { partId String @id @default(uuid()) - organizationId String - organization Organization @relation(fields: [organizationId], references: [organizationId]) index Int commonName String description String? @@ -1153,14 +1150,14 @@ model Part { } model PartTag { - id String @id @default(uuid()) + partTagId String @id @default(uuid()) name String - color String + colorHexCode String dateCreated DateTime dateDeleted DateTime? parts Part[] - Organization Organization? @relation(fields: [OrganizationId], references: [organizationId]) - OrganizationId String? + organization Organization? @relation(fields: [organizationId], references: [organizationId]) + organizationId String? } model PartSubmission { @@ -1221,6 +1218,6 @@ model PartReviewCommonMistake { userDeletedId String? dateCreated DateTime @default(now()) dateDeleted DateTime? - Organization Organization? @relation(fields: [OrganizationId], references: [organizationId]) - OrganizationId String? + organization Organization? @relation(fields: [organizationId], references: [organizationId]) + organizationId String? } diff --git a/src/backend/src/prisma/seed.ts b/src/backend/src/prisma/seed.ts index a4d7975763..9401dad479 100644 --- a/src/backend/src/prisma/seed.ts +++ b/src/backend/src/prisma/seed.ts @@ -1998,9 +1998,19 @@ const performSeed: () => Promise = async () => { await RecruitmentServices.createMilestone(batman, 'Applications Close', '', new Date('11/27/24'), ner); await RecruitmentServices.createMilestone(batman, 'Decision Day!', '', new Date('12/4/24'), ner); - await RecruitmentServices.createFaq(batman, 'Who is the Chief Software Engineer?', 'Peyton McKee', ner); - await RecruitmentServices.createFaq(batman, 'When was FinishLine created?', 'FinishLine was created in 2019', ner); - await RecruitmentServices.createFaq(batman, 'How many developers are working on FinishLine?', '178 as of 2024', ner); + await RecruitmentServices.createOrganizationFaq(batman, 'Who is the Chief Software Engineer?', 'Peyton McKee', ner); + await RecruitmentServices.createOrganizationFaq( + batman, + 'When was FinishLine created?', + 'FinishLine was created in 2019', + ner + ); + await RecruitmentServices.createOrganizationFaq( + batman, + 'How many developers are working on FinishLine?', + '178 as of 2024', + ner + ); await AnnouncementService.createAnnouncement( 'Welcome to Finishline!', diff --git a/src/backend/src/routes/recruitment.routes.ts b/src/backend/src/routes/recruitment.routes.ts index 2b7ae7b201..7a5c932fb5 100644 --- a/src/backend/src/routes/recruitment.routes.ts +++ b/src/backend/src/routes/recruitment.routes.ts @@ -30,14 +30,14 @@ recruitmentRouter.delete('/milestone/:milestoneId/delete', RecruitmentController /* FAQ Section */ -recruitmentRouter.get('/faqs', RecruitmentController.getAllFaqs); +recruitmentRouter.get('/faqs', RecruitmentController.getAllOrganizationFaqs); recruitmentRouter.post( '/faq/create', nonEmptyString(body('question')), nonEmptyString(body('answer')), validateInputs, - RecruitmentController.createFaq + RecruitmentController.createOrganizationFaq ); recruitmentRouter.post( diff --git a/src/backend/src/services/recruitment.services.ts b/src/backend/src/services/recruitment.services.ts index 089e0c1c4b..7fd6975ded 100644 --- a/src/backend/src/services/recruitment.services.ts +++ b/src/backend/src/services/recruitment.services.ts @@ -104,7 +104,7 @@ export default class RecruitmentServices { * @param organizationId organization Id of the faq * @returns all the faqs from the given organization */ - static async getAllFaqs(organization: Organization) { + static async getAllOrganizationFaqs(organization: Organization) { const allFaqs = await prisma.frequentlyAskedQuestion.findMany({ where: { dateDeleted: null, regularFaqOrgId: organization.organizationId } }); @@ -142,7 +142,7 @@ export default class RecruitmentServices { * @param organizationId the organization Id of the FAQ * @returns A newly created FAQ */ - static async createFaq(submitter: User, question: string, answer: string, organization: Organization) { + static async createOrganizationFaq(submitter: User, question: string, answer: string, organization: Organization) { if (!(await userHasPermission(submitter.userId, organization.organizationId, isAdmin))) throw new AccessDeniedAdminOnlyException('create an faq'); From c2e2387ec5d251322314829706d827a1b88f9940 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Fri, 24 Jan 2025 19:10:14 -0500 Subject: [PATCH 13/13] #3124 fixed tests --- src/backend/tests/unit/recruitment.test.ts | 22 ++++++++++++++----- .../tests/unmocked/recruitment.test.ts | 22 ++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/backend/tests/unit/recruitment.test.ts b/src/backend/tests/unit/recruitment.test.ts index dddb6a6ba6..3efaab8cc5 100644 --- a/src/backend/tests/unit/recruitment.test.ts +++ b/src/backend/tests/unit/recruitment.test.ts @@ -39,19 +39,19 @@ describe('Recruitment Tests', () => { describe('Get All FAQs', () => { it('Succeeds and gets all the FAQs', async () => { - const faq1 = await RecruitmentServices.createFaq( + const faq1 = await RecruitmentServices.createOrganizationFaq( await createTestUser(batmanAppAdmin, orgId), 'question', 'answer', organization ); - const faq2 = await RecruitmentServices.createFaq( + const faq2 = await RecruitmentServices.createOrganizationFaq( await createTestUser(supermanAdmin, orgId), 'question2', 'answer2', organization ); - const result = await RecruitmentServices.getAllFaqs(organization); + const result = await RecruitmentServices.getAllOrganizationFaqs(organization); expect(result).toStrictEqual([faq1, faq2]); }); @@ -233,7 +233,12 @@ describe('Recruitment Tests', () => { it('Fails if user is not an admin', async () => { await expect( async () => - await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization) + await RecruitmentServices.createOrganizationFaq( + await createTestUser(member, orgId), + 'question', + 'answer', + organization + ) ).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq')); }); @@ -279,12 +284,17 @@ describe('Recruitment Tests', () => { it('Fails if user is not an admin', async () => { await expect( async () => - await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization) + await RecruitmentServices.createOrganizationFaq( + await createTestUser(member, orgId), + 'question', + 'answer', + organization + ) ).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq')); }); it('Succeeds and creates an FAQ', async () => { - const result = await RecruitmentServices.createFaq( + const result = await RecruitmentServices.createOrganizationFaq( await createTestUser(batmanAppAdmin, orgId), 'question', 'answer', diff --git a/src/backend/tests/unmocked/recruitment.test.ts b/src/backend/tests/unmocked/recruitment.test.ts index dddb6a6ba6..3efaab8cc5 100644 --- a/src/backend/tests/unmocked/recruitment.test.ts +++ b/src/backend/tests/unmocked/recruitment.test.ts @@ -39,19 +39,19 @@ describe('Recruitment Tests', () => { describe('Get All FAQs', () => { it('Succeeds and gets all the FAQs', async () => { - const faq1 = await RecruitmentServices.createFaq( + const faq1 = await RecruitmentServices.createOrganizationFaq( await createTestUser(batmanAppAdmin, orgId), 'question', 'answer', organization ); - const faq2 = await RecruitmentServices.createFaq( + const faq2 = await RecruitmentServices.createOrganizationFaq( await createTestUser(supermanAdmin, orgId), 'question2', 'answer2', organization ); - const result = await RecruitmentServices.getAllFaqs(organization); + const result = await RecruitmentServices.getAllOrganizationFaqs(organization); expect(result).toStrictEqual([faq1, faq2]); }); @@ -233,7 +233,12 @@ describe('Recruitment Tests', () => { it('Fails if user is not an admin', async () => { await expect( async () => - await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization) + await RecruitmentServices.createOrganizationFaq( + await createTestUser(member, orgId), + 'question', + 'answer', + organization + ) ).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq')); }); @@ -279,12 +284,17 @@ describe('Recruitment Tests', () => { it('Fails if user is not an admin', async () => { await expect( async () => - await RecruitmentServices.createFaq(await createTestUser(member, orgId), 'question', 'answer', organization) + await RecruitmentServices.createOrganizationFaq( + await createTestUser(member, orgId), + 'question', + 'answer', + organization + ) ).rejects.toThrow(new AccessDeniedAdminOnlyException('create an faq')); }); it('Succeeds and creates an FAQ', async () => { - const result = await RecruitmentServices.createFaq( + const result = await RecruitmentServices.createOrganizationFaq( await createTestUser(batmanAppAdmin, orgId), 'question', 'answer',