Fix project detail 500 error and round deletion data integrity

- Add missing migration for FileRequirement table and ProjectFile.requirementId
  column (existed in Prisma schema but had no migration, causing all queries
  with `include: { files: true }` to fail with column not found)
- Make projectTags query resilient with try-catch in project.get
- Reset project status to SUBMITTED when round is deleted (prevents orphaned
  ASSIGNED status after ON DELETE SET NULL nullifies roundId)
- Fix round creation/update to allow requiredReviews=0 for filtering rounds
- Parse Zod validation errors in round creation error display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 00:20:28 +01:00
parent 0631dbb64f
commit 7e3d600eed
4 changed files with 65 additions and 11 deletions

View File

@@ -327,17 +327,21 @@ export const projectRouter = router({
},
},
},
projectTags: {
include: {
tag: {
select: { id: true, name: true, category: true, color: true },
},
},
orderBy: { confidence: 'desc' },
},
},
})
// Fetch project tags separately (table may not exist if migrations are pending)
let projectTags: { id: string; projectId: string; tagId: string; confidence: number; tag: { id: string; name: string; category: string | null; color: string | null } }[] = []
try {
projectTags = await ctx.prisma.projectTag.findMany({
where: { projectId: input.id },
include: { tag: { select: { id: true, name: true, category: true, color: true } } },
orderBy: { confidence: 'desc' },
})
} catch {
// ProjectTag table may not exist yet
}
// Check access for jury members
if (ctx.user.role === 'JURY_MEMBER') {
const assignment = await ctx.prisma.assignment.findFirst({
@@ -381,6 +385,7 @@ export const projectRouter = router({
return {
...project,
projectTags,
teamMembers: teamMembersWithAvatars,
mentorAssignment: mentorWithAvatar,
}