Skip to content

Commit

Permalink
enhance(prisma): make user proposal many-to-many explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
rschlaefli committed Oct 11, 2022
1 parent a358cde commit f1a690d
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ model User {
accounts Account[]
assignedProposal Proposal? @relation("proposalAssignment")
assignedProposalId String?
supervises Proposal[] @relation("proposalSupervision")
appliedFor Proposal[] @relation("proposalApplication")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
assignedProposals UserProposalAssignment[]
supervisedProposals UserProposalSupervision[]
appliedFor UserProposalApplication[]
}

model VerificationToken {
Expand All @@ -93,12 +91,40 @@ model Proposal {
type ProposalType
status ProposalStatus @default(OPEN)
assignedTo User? @relation("proposalAssignment", fields: [assignedToStudentId], references: [id])
assignedToStudentId String? @unique
supervisedBy User[] @relation("proposalSupervision")
applicants User[] @relation("proposalApplication")
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
assignedTo UserProposalAssignment[]
supervisedBy UserProposalSupervision[]
applications UserProposalApplication[]
}

model UserProposalAssignment {
proposal Proposal @relation(fields: [proposalId], references: [id])
proposalId String
user User @relation(fields: [userId], references: [id])
userId String
@@unique([proposalId, userId])
}

model UserProposalSupervision {
proposal Proposal @relation(fields: [proposalId], references: [id])
proposalId String
user User @relation(fields: [userId], references: [id])
userId String
@@unique([proposalId, userId])
}

model UserProposalApplication {
proposal Proposal @relation(fields: [proposalId], references: [id])
proposalId String
user User @relation(fields: [userId], references: [id])
userId String
@@unique([proposalId, userId])
}

0 comments on commit f1a690d

Please sign in to comment.