refactor(schema-cascade): rename Project.mentorAssignment → mentorAssignments
Schema dropped @unique on MentorAssignment.projectId in PR8 Task 1 →
back-relation becomes a list. Mechanical rename of Prisma queries and
consumer accessors. Legacy single-mentor callers use [0] with a TODO for
PR8 Task 8 to surface the full list. mentor-workspace.ts is left as Task 5.
- routers (mentor, project, applicant, finalist, round) and smart-assignment
service: include/where/select keys renamed; `mentorAssignment: null` →
`mentorAssignments: { none: {} }`; `{ isNot: null }` → `{ some: {} }`.
- UI consumers (mentor + applicant pages): `project.mentorAssignment` →
`project.mentorAssignments[0]` with TODO markers.
- Tests: `findUnique({ projectId })` → `findFirst({ projectId })` since the
composite key now requires both projectId+mentorId. MentorFile.create gains
the new required projectId.
- Workspace endpoints in mentor.ts now guard null mentorAssignmentId until
Task 5 re-scopes them to project.
- finalist.unconfirm now cascades to ALL active mentor assignments.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -213,12 +213,12 @@ describe('mentor.autoAssignBulkForRound', () => {
|
||||
|
||||
expect(result.assigned).toBe(1)
|
||||
|
||||
const requestedAssigned = await prisma.mentorAssignment.findUnique({
|
||||
const requestedAssigned = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projWithRequest.id },
|
||||
})
|
||||
expect(requestedAssigned).not.toBeNull()
|
||||
|
||||
const skippedNotAssigned = await prisma.mentorAssignment.findUnique({
|
||||
const skippedNotAssigned = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projWithoutRequest.id },
|
||||
})
|
||||
expect(skippedNotAssigned).toBeNull()
|
||||
@@ -291,7 +291,7 @@ describe('mentor.autoAssignBulkForRound', () => {
|
||||
expect(result.assigned).toBe(1)
|
||||
expect(result.skipped).toBe(1)
|
||||
|
||||
const stillExisting = await prisma.mentorAssignment.findUnique({
|
||||
const stillExisting = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projAlreadyAssigned.id },
|
||||
})
|
||||
expect(stillExisting?.mentorId).toBe(existingMentor.id) // unchanged
|
||||
@@ -377,17 +377,17 @@ describe('mentor.autoAssignBulkForRound', () => {
|
||||
|
||||
expect(result.assigned).toBe(1)
|
||||
|
||||
const confirmedAssigned = await prisma.mentorAssignment.findUnique({
|
||||
const confirmedAssigned = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projConfirmed.id },
|
||||
})
|
||||
expect(confirmedAssigned).not.toBeNull()
|
||||
|
||||
const pendingAssigned = await prisma.mentorAssignment.findUnique({
|
||||
const pendingAssigned = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projPending.id },
|
||||
})
|
||||
expect(pendingAssigned).toBeNull()
|
||||
|
||||
const noConfAssigned = await prisma.mentorAssignment.findUnique({
|
||||
const noConfAssigned = await prisma.mentorAssignment.findFirst({
|
||||
where: { projectId: projNoConfirmation.id },
|
||||
})
|
||||
expect(noConfAssigned).toBeNull()
|
||||
|
||||
@@ -92,6 +92,7 @@ describe('mentor.getRoundStats', () => {
|
||||
})
|
||||
await prisma.mentorFile.create({
|
||||
data: {
|
||||
projectId: projReqAssigned.id,
|
||||
mentorAssignmentId: a1.id,
|
||||
uploadedByUserId: mentor.id,
|
||||
fileName: 'plan.pdf',
|
||||
|
||||
Reference in New Issue
Block a user