Skip to content

Commit

Permalink
#2708 merged develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaryan1203 committed Jul 30, 2024
2 parents 41b1129 + b6030f0 commit 50e454d
Show file tree
Hide file tree
Showing 20 changed files with 348 additions and 146 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@types/react-dom": "17.0.1"
},
"dependencies": {
"react-hook-form-persist": "^3.0.0",
"typescript": "^4.1.5"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- CreateTable
CREATE TABLE "FrequentlyAskedQuestion" (
"frequentlyAskedQuestionId" 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),
"organizationId" TEXT NOT NULL,

CONSTRAINT "FrequentlyAskedQuestion_pkey" PRIMARY KEY ("frequentlyAskedQuestionId")
);

-- CreateTable
CREATE TABLE "Milestone" (
"milestoneId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"dateOfEvent" TIMESTAMP(3) NOT NULL,
"description" TEXT NOT NULL,
"userCreatedId" TEXT NOT NULL,
"userDeletedId" TEXT,
"dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"dateDeleted" TIMESTAMP(3),
"organizationId" TEXT NOT NULL,

CONSTRAINT "Milestone_pkey" PRIMARY KEY ("milestoneId")
);

-- AddForeignKey
ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "FrequentlyAskedQuestion" ADD CONSTRAINT "FrequentlyAskedQuestion_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Milestone" ADD CONSTRAINT "Milestone_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Milestone" ADD CONSTRAINT "Milestone_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Milestone" ADD CONSTRAINT "Milestone_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "description" TEXT DEFAULT 'Default description';

ALTER TABLE "Organization" ALTER COLUMN "description" DROP DEFAULT;

ALTER TABLE "Organization" ALTER COLUMN "description" SET NOT NULL;
199 changes: 118 additions & 81 deletions src/backend/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -109,71 +109,76 @@ enum Design_Review_Status {
}

model User {
userId String @id @default(uuid())
firstName String
lastName String
googleAuthId String @unique
email String @unique
emailId String? @unique
roles Role[]
userSettings User_Settings?
userSecureSettings User_Secure_Settings?
userId String @id @default(uuid())
firstName String
lastName String
googleAuthId String @unique
email String @unique
emailId String? @unique
roles Role[]
userSettings User_Settings?
userSecureSettings User_Secure_Settings?
// Relation references
submittedChangeRequests Change_Request[] @relation(name: "submittedChangeRequests")
reviewedChangeRequests Change_Request[] @relation(name: "reviewedChangeRequests")
deletedChangeRequests Change_Request[] @relation(name: "deletedChangeRequests")
changeRequestsToReview Change_Request[] @relation(name: "requestedChangeRequestReviewers")
markedAslead Activation_CR[] @relation(name: "markAsLead")
markedAsmanager Activation_CR[] @relation(name: "markAsManager")
changes Change[]
lead WBS_Element[] @relation(name: "lead")
manager WBS_Element[] @relation(name: "manager")
Session Session[]
teamsAsMember Team[] @relation(name: "teamsAsMember")
teamsAsHead Team[] @relation(name: "teamsAsHead")
teamsAsLead Team[] @relation(name: "teamsAsLead")
deletedWBSElements WBS_Element[] @relation(name: "deletedWbsElements")
checkedDescriptionBullets Description_Bullet[] @relation(name: "checkDescriptionBullets")
createdProposedSolutions Proposed_Solution[]
createdTasks Task[] @relation(name: "createdBy")
deletedTasks Task[] @relation(name: "deletedBy")
assignedTasks Task[] @relation(name: "assignedTo")
favoriteProjects Project[] @relation(name: "favoritedBy")
reimbursementRequests Reimbursement_Request[] @relation(name: "reimbursementRequestRecipient")
reimbursementStatuses Reimbursement_Status[]
reimbursements Reimbursement[] @relation(name: "purchaser")
submittedReimbursements Reimbursement[] @relation(name: "submitter")
createdLinks Link[] @relation(name: "linkCreator")
createdLinkTypes Link_Type[] @relation(name: "linkTypeCreator")
deletedReceipts Receipt[] @relation(name: "deletedReceipts")
createdReceipts Receipt[] @relation(name: "receiptsCreatedBy")
deletedAssemblies Assembly[] @relation(name: "assemblyDeleter")
createdAssemblies Assembly[] @relation(name: "assemblyCreator")
deletedMaterials Material[] @relation(name: "materialDeleter")
createdMaterials Material[] @relation(name: "materialCreator")
archivedTeams Team[] @relation(name: "userArchived")
createdMaterialTypes Material_Type[] @relation(name: "materialTypeCreator")
createdManufacturers Manufacturer[] @relation(name: "manufacturerCreator")
requiredDesignReviews Design_Review[] @relation(name: "requiredAttendee")
optionalDesignReviews Design_Review[] @relation(name: "optionalAttendee")
userConfirmedDesignReviews Design_Review[] @relation(name: "confirmedAttendee")
userDeniedDesignReviews Design_Review[] @relation(name: "deniedAttendee")
attendedDesignReviews Design_Review[] @relation(name: "userAttended")
createdDesignReviews Design_Review[] @relation(name: "designReviewCreator")
deletedDesignReviews Design_Review[] @relation(name: "designReviewDeleter")
drScheduleSettings Schedule_Settings?
createdWorkPackageTemplate Work_Package_Template[] @relation(name: "workPackageTemplateCreator")
deletedWorkPackageTemplate Work_Package_Template[] @relation(name: "workPackageTemplateDeleter")
wbsProposedlead Wbs_Proposed_Changes[] @relation(name: "wbslead")
wbsProposedmanager Wbs_Proposed_Changes[] @relation(name: "wbsmanager")
organizations Organization[] @relation(name: "organizationMembers")
deletedOrganizations Organization[] @relation(name: "organizationDeleter")
createdOrganizations Organization[] @relation(name: "organizationCreator")
createdDescriptionBullets Description_Bullet_Type[] @relation(name: "descriptionBulletTypeCreator")
deletedDescriptionBullets Description_Bullet_Type[] @relation(name: "descriptionBulletTypeDeleter")
createdUnits Unit[] @relation(name: "unitCreator")
organizationsAsAdvisor Organization[] @relation(name: "advisor")
organizationsAsTreasurer Organization[] @relation(name: "treasurer")
submittedChangeRequests Change_Request[] @relation(name: "submittedChangeRequests")
reviewedChangeRequests Change_Request[] @relation(name: "reviewedChangeRequests")
deletedChangeRequests Change_Request[] @relation(name: "deletedChangeRequests")
changeRequestsToReview Change_Request[] @relation(name: "requestedChangeRequestReviewers")
markedAslead Activation_CR[] @relation(name: "markAsLead")
markedAsmanager Activation_CR[] @relation(name: "markAsManager")
changes Change[]
lead WBS_Element[] @relation(name: "lead")
manager WBS_Element[] @relation(name: "manager")
Session Session[]
teamsAsMember Team[] @relation(name: "teamsAsMember")
teamsAsHead Team[] @relation(name: "teamsAsHead")
teamsAsLead Team[] @relation(name: "teamsAsLead")
deletedWBSElements WBS_Element[] @relation(name: "deletedWbsElements")
checkedDescriptionBullets Description_Bullet[] @relation(name: "checkDescriptionBullets")
createdProposedSolutions Proposed_Solution[]
createdTasks Task[] @relation(name: "createdBy")
deletedTasks Task[] @relation(name: "deletedBy")
assignedTasks Task[] @relation(name: "assignedTo")
favoriteProjects Project[] @relation(name: "favoritedBy")
reimbursementRequests Reimbursement_Request[] @relation(name: "reimbursementRequestRecipient")
reimbursementStatuses Reimbursement_Status[]
reimbursements Reimbursement[] @relation(name: "purchaser")
submittedReimbursements Reimbursement[] @relation(name: "submitter")
createdLinks Link[] @relation(name: "linkCreator")
createdLinkTypes Link_Type[] @relation(name: "linkTypeCreator")
deletedReceipts Receipt[] @relation(name: "deletedReceipts")
createdReceipts Receipt[] @relation(name: "receiptsCreatedBy")
deletedAssemblies Assembly[] @relation(name: "assemblyDeleter")
createdAssemblies Assembly[] @relation(name: "assemblyCreator")
deletedMaterials Material[] @relation(name: "materialDeleter")
createdMaterials Material[] @relation(name: "materialCreator")
archivedTeams Team[] @relation(name: "userArchived")
createdMaterialTypes Material_Type[] @relation(name: "materialTypeCreator")
createdManufacturers Manufacturer[] @relation(name: "manufacturerCreator")
requiredDesignReviews Design_Review[] @relation(name: "requiredAttendee")
optionalDesignReviews Design_Review[] @relation(name: "optionalAttendee")
userConfirmedDesignReviews Design_Review[] @relation(name: "confirmedAttendee")
userDeniedDesignReviews Design_Review[] @relation(name: "deniedAttendee")
attendedDesignReviews Design_Review[] @relation(name: "userAttended")
createdDesignReviews Design_Review[] @relation(name: "designReviewCreator")
deletedDesignReviews Design_Review[] @relation(name: "designReviewDeleter")
drScheduleSettings Schedule_Settings?
createdWorkPackageTemplate Work_Package_Template[] @relation(name: "workPackageTemplateCreator")
deletedWorkPackageTemplate Work_Package_Template[] @relation(name: "workPackageTemplateDeleter")
wbsProposedlead Wbs_Proposed_Changes[] @relation(name: "wbslead")
wbsProposedmanager Wbs_Proposed_Changes[] @relation(name: "wbsmanager")
organizations Organization[] @relation(name: "organizationMembers")
deletedOrganizations Organization[] @relation(name: "organizationDeleter")
createdOrganizations Organization[] @relation(name: "organizationCreator")
createdDescriptionBullets Description_Bullet_Type[] @relation(name: "descriptionBulletTypeCreator")
deletedDescriptionBullets Description_Bullet_Type[] @relation(name: "descriptionBulletTypeDeleter")
createdUnits Unit[] @relation(name: "unitCreator")
organizationsAsAdvisor Organization[] @relation(name: "advisor")
organizationsAsTreasurer Organization[] @relation(name: "treasurer")
createdFrequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "frequentlyAskedQuestionCreator")
deletedFrequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "frequentlyAskedQuestionDeleter")
createdMilestones Milestone[] @relation(name: "milestoneCreator")
deletedMilestones Milestone[] @relation(name: "milestoneDeleter")
}

model Role {
Expand Down Expand Up @@ -856,23 +861,55 @@ model Organization {
treasurer User? @relation(name: "treasurer", fields: [treasurerId], references: [userId])
advisor User? @relation(name: "advisor", fields: [advisorId], references: [userId])
advisorId String?
description String
// Relation references
wbsElements WBS_Element[]
users User[] @relation(name: "organizationMembers")
linkTypes Link_Type[]
materialTypes Material_Type[]
manufacturers Manufacturer[]
teamTypes Team_Type[]
teams Team[]
vendors Vendor[]
expenseTypes Account_Code[]
reimbursements Reimbursement[]
units Unit[]
descriptionBulletTypes Description_Bullet_Type[]
workPackageTemplates Work_Package_Template[]
roles Role[]
changeRequests Change_Request[]
reimbursementReqeusts Reimbursement_Request[]
usefulLinks Link[]
wbsElements WBS_Element[]
users User[] @relation(name: "organizationMembers")
linkTypes Link_Type[]
materialTypes Material_Type[]
manufacturers Manufacturer[]
teamTypes Team_Type[]
teams Team[]
vendors Vendor[]
expenseTypes Account_Code[]
reimbursements Reimbursement[]
units Unit[]
descriptionBulletTypes Description_Bullet_Type[]
workPackageTemplates Work_Package_Template[]
roles Role[]
changeRequests Change_Request[]
reimbursementReqeusts Reimbursement_Request[]
usefulLinks Link[]
FrequentlyAskedQuestions FrequentlyAskedQuestion[]
Milestone Milestone[]
}

model FrequentlyAskedQuestion {
frequentlyAskedQuestionId 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])
}

model Milestone {
milestoneId String @id @default(uuid())
name String
dateOfEvent DateTime
description String
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "milestoneCreator")
userCreatedId String
userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "milestoneDeleter")
userDeletedId String?
dateCreated DateTime @default(now())
dateDeleted DateTime?
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
}
4 changes: 3 additions & 1 deletion src/backend/src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ const performSeed: () => Promise<void> = async () => {
const ner = await prisma.organization.create({
data: {
name: 'NER',
userCreatedId: thomasEmrax.userId
userCreatedId: thomasEmrax.userId,
description:
'Northeastern Electric Racing is a student-run organization at Northeastern University building all-electric formula-style race cars from scratch to compete in Forumla Hybrid + Electric Formula SAE (FSAE).'
}
});

Expand Down
Loading

0 comments on commit 50e454d

Please sign in to comment.