Skip to content

Commit a83384b

Browse files
committed
feat: add DTOs for program B mentor assignment and document uploads, and update project modules
1 parent 3f5cb03 commit a83384b

21 files changed

Lines changed: 2482 additions & 137 deletions
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
ALTER TYPE "BacklogItemStatus" ADD VALUE IF NOT EXISTS 'IN_PAIRING';
2+
ALTER TYPE "BacklogItemStatus" ADD VALUE IF NOT EXISTS 'ASSIGNED';
3+
ALTER TYPE "BacklogItemStatus" ADD VALUE IF NOT EXISTS 'IN_REALIZATION';
4+
ALTER TYPE "BacklogItemStatus" ADD VALUE IF NOT EXISTS 'CLOSED';
5+
6+
CREATE TYPE "ProgramBBacklogDocumentCategory" AS ENUM (
7+
'TECHNICAL_SPECIFICATION',
8+
'SUPPORTING',
9+
'OTHER'
10+
);
11+
12+
CREATE TYPE "ProgramBProjectDocumentCategory" AS ENUM (
13+
'OUTPUT',
14+
'FINAL_PRESENTATION',
15+
'DELIVERABLE',
16+
'OTHER'
17+
);
18+
19+
CREATE TYPE "ProgramBDocumentVisibility" AS ENUM (
20+
'INTERNAL',
21+
'PARTICIPANTS'
22+
);
23+
24+
ALTER TABLE "ProgramBProject"
25+
ADD COLUMN "mentorUserId" TEXT,
26+
ADD COLUMN "mentorAssignedAt" TIMESTAMP(3),
27+
ADD COLUMN "mentorAssignedById" TEXT;
28+
29+
CREATE TABLE "ProgramBBacklogDocument" (
30+
"id" TEXT NOT NULL,
31+
"backlogItemId" TEXT NOT NULL,
32+
"uploadedFileId" TEXT NOT NULL,
33+
"category" "ProgramBBacklogDocumentCategory" NOT NULL,
34+
"visibility" "ProgramBDocumentVisibility" NOT NULL DEFAULT 'PARTICIPANTS',
35+
"version" INTEGER NOT NULL DEFAULT 1,
36+
"isActive" BOOLEAN NOT NULL DEFAULT true,
37+
"createdById" TEXT NOT NULL,
38+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
39+
"updatedAt" TIMESTAMP(3) NOT NULL,
40+
CONSTRAINT "ProgramBBacklogDocument_pkey" PRIMARY KEY ("id")
41+
);
42+
43+
CREATE TABLE "ProgramBProjectDocument" (
44+
"id" TEXT NOT NULL,
45+
"projectId" TEXT NOT NULL,
46+
"uploadedFileId" TEXT NOT NULL,
47+
"category" "ProgramBProjectDocumentCategory" NOT NULL,
48+
"visibility" "ProgramBDocumentVisibility" NOT NULL DEFAULT 'PARTICIPANTS',
49+
"version" INTEGER NOT NULL DEFAULT 1,
50+
"isActive" BOOLEAN NOT NULL DEFAULT true,
51+
"createdById" TEXT NOT NULL,
52+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
53+
"updatedAt" TIMESTAMP(3) NOT NULL,
54+
CONSTRAINT "ProgramBProjectDocument_pkey" PRIMARY KEY ("id")
55+
);
56+
57+
CREATE INDEX "ProgramBProject_mentorUserId_idx" ON "ProgramBProject"("mentorUserId");
58+
CREATE INDEX "ProgramBProject_mentorAssignedById_idx" ON "ProgramBProject"("mentorAssignedById");
59+
CREATE INDEX "ProgramBBacklogDocument_backlogItemId_category_isActive_idx" ON "ProgramBBacklogDocument"("backlogItemId", "category", "isActive");
60+
CREATE INDEX "ProgramBBacklogDocument_uploadedFileId_idx" ON "ProgramBBacklogDocument"("uploadedFileId");
61+
CREATE INDEX "ProgramBProjectDocument_projectId_category_isActive_idx" ON "ProgramBProjectDocument"("projectId", "category", "isActive");
62+
CREATE INDEX "ProgramBProjectDocument_uploadedFileId_idx" ON "ProgramBProjectDocument"("uploadedFileId");
63+
64+
ALTER TABLE "ProgramBProject"
65+
ADD CONSTRAINT "ProgramBProject_mentorUserId_fkey"
66+
FOREIGN KEY ("mentorUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
67+
68+
ALTER TABLE "ProgramBProject"
69+
ADD CONSTRAINT "ProgramBProject_mentorAssignedById_fkey"
70+
FOREIGN KEY ("mentorAssignedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
71+
72+
ALTER TABLE "ProgramBBacklogDocument"
73+
ADD CONSTRAINT "ProgramBBacklogDocument_backlogItemId_fkey"
74+
FOREIGN KEY ("backlogItemId") REFERENCES "BacklogItem"("id") ON DELETE CASCADE ON UPDATE CASCADE;
75+
76+
ALTER TABLE "ProgramBBacklogDocument"
77+
ADD CONSTRAINT "ProgramBBacklogDocument_uploadedFileId_fkey"
78+
FOREIGN KEY ("uploadedFileId") REFERENCES "UploadedFile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
79+
80+
ALTER TABLE "ProgramBBacklogDocument"
81+
ADD CONSTRAINT "ProgramBBacklogDocument_createdById_fkey"
82+
FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
83+
84+
ALTER TABLE "ProgramBProjectDocument"
85+
ADD CONSTRAINT "ProgramBProjectDocument_projectId_fkey"
86+
FOREIGN KEY ("projectId") REFERENCES "ProgramBProject"("id") ON DELETE CASCADE ON UPDATE CASCADE;
87+
88+
ALTER TABLE "ProgramBProjectDocument"
89+
ADD CONSTRAINT "ProgramBProjectDocument_uploadedFileId_fkey"
90+
FOREIGN KEY ("uploadedFileId") REFERENCES "UploadedFile"("id") ON DELETE CASCADE ON UPDATE CASCADE;
91+
92+
ALTER TABLE "ProgramBProjectDocument"
93+
ADD CONSTRAINT "ProgramBProjectDocument_createdById_fkey"
94+
FOREIGN KEY ("createdById") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

prisma/schema.prisma

Lines changed: 100 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ enum ProgramType {
5252
enum BacklogItemStatus {
5353
DRAFT
5454
PUBLISHED
55+
IN_PAIRING
56+
ASSIGNED
57+
IN_REALIZATION
58+
CLOSED
5559
ARCHIVED
5660
}
5761

@@ -186,6 +190,24 @@ enum ProgramBPoDecision {
186190
CHANGES_REQUESTED
187191
}
188192

193+
enum ProgramBBacklogDocumentCategory {
194+
TECHNICAL_SPECIFICATION
195+
SUPPORTING
196+
OTHER
197+
}
198+
199+
enum ProgramBProjectDocumentCategory {
200+
OUTPUT
201+
FINAL_PRESENTATION
202+
DELIVERABLE
203+
OTHER
204+
}
205+
206+
enum ProgramBDocumentVisibility {
207+
INTERNAL
208+
PARTICIPANTS
209+
}
210+
189211
model User {
190212
id String @id @default(uuid())
191213
firstName String
@@ -220,19 +242,21 @@ model User {
220242
uploads UploadedFile[]
221243
organizationDocumentsUploaded OrganizationDocument[] @relation("OrganizationDocumentUploadedBy")
222244
223-
applicationsCreated Application[] @relation("ApplicationCreatedBy")
224-
assignedProgramAApplications Application[] @relation("ApplicationAssignedMentor")
225-
applicationEvaluations ApplicationEvaluation[] @relation("ApplicationEvaluationEvaluator")
226-
applicationDecisions Application[] @relation("ApplicationDecisionBy")
227-
programAMentorAssignmentsMade Application[] @relation("ApplicationMentorAssignedBy")
228-
updatedApplicationSections ApplicationSection[] @relation("ApplicationSectionUpdatedBy")
229-
applicationSectionHistories ApplicationSectionHistory[] @relation("SectionHistorySavedBy")
230-
applicationDocumentsCreated ApplicationDocument[] @relation("ApplicationDocumentCreatedBy")
231-
applicationDocumentsForMember ApplicationDocument[] @relation("ApplicationDocumentMember")
232-
productOwnerForBacklogItems BacklogItem[] @relation("BacklogItemProductOwner")
233-
productOwnerForProgramBProjects ProgramBProject[] @relation("ProgramBProjectProductOwner")
234-
programBMentoringNotesAuthored ProgramBMentoringNote[] @relation("ProgramBMentoringNoteAuthor")
235-
programBPoReviewsAuthored ProgramBPoReview[] @relation("ProgramBPoReviewAuthor")
245+
applicationsCreated Application[] @relation("ApplicationCreatedBy")
246+
assignedProgramAApplications Application[] @relation("ApplicationAssignedMentor")
247+
applicationEvaluations ApplicationEvaluation[] @relation("ApplicationEvaluationEvaluator")
248+
applicationDecisions Application[] @relation("ApplicationDecisionBy")
249+
programAMentorAssignmentsMade Application[] @relation("ApplicationMentorAssignedBy")
250+
updatedApplicationSections ApplicationSection[] @relation("ApplicationSectionUpdatedBy")
251+
applicationSectionHistories ApplicationSectionHistory[] @relation("SectionHistorySavedBy")
252+
applicationDocumentsCreated ApplicationDocument[] @relation("ApplicationDocumentCreatedBy")
253+
applicationDocumentsForMember ApplicationDocument[] @relation("ApplicationDocumentMember")
254+
productOwnerForBacklogItems BacklogItem[] @relation("BacklogItemProductOwner")
255+
productOwnerForProgramBProjects ProgramBProject[] @relation("ProgramBProjectProductOwner")
256+
assignedProgramBProjectsAsMentor ProgramBProject[] @relation("ProgramBProjectMentor")
257+
programBMentorAssignmentsMade ProgramBProject[] @relation("ProgramBProjectMentorAssignedBy")
258+
programBMentoringNotesAuthored ProgramBMentoringNote[] @relation("ProgramBMentoringNoteAuthor")
259+
programBPoReviewsAuthored ProgramBPoReview[] @relation("ProgramBPoReviewAuthor")
236260
237261
needsInfoItemsCreated NeedsInfoItem[] @relation("NeedsInfoCreatedBy")
238262
needsInfoItemsResolved NeedsInfoItem[] @relation("NeedsInfoResolvedBy")
@@ -244,6 +268,8 @@ model User {
244268
updatedAt DateTime @updatedAt
245269
programBTeamApplications ProgramBTeamApplication[]
246270
programBTeamApplicationCvs ProgramBTeamApplicationCv[]
271+
programBBacklogDocuments ProgramBBacklogDocument[]
272+
programBProjectDocuments ProgramBProjectDocument[]
247273
248274
@@index([organizationId])
249275
@@index([role, status])
@@ -278,6 +304,8 @@ model UploadedFile {
278304
cvFor StudentProfile[] @relation("StudentCvFile")
279305
applicationDocuments ApplicationDocument[]
280306
programBTeamApplications ProgramBTeamApplication[]
307+
programBBacklogDocuments ProgramBBacklogDocument[]
308+
programBProjectDocuments ProgramBProjectDocument[]
281309
programBTeamApplicationCvs ProgramBTeamApplicationCv[]
282310
283311
@@index([ownerId, status])
@@ -533,6 +561,7 @@ model BacklogItem {
533561
createdAt DateTime @default(now())
534562
updatedAt DateTime @updatedAt
535563
programBTeamApplications ProgramBTeamApplication[]
564+
documents ProgramBBacklogDocument[]
536565
537566
@@index([organizationId])
538567
@@index([status])
@@ -710,6 +739,13 @@ model ProgramBProject {
710739
productOwnerUserId String
711740
productOwnerUser User @relation("ProgramBProjectProductOwner", fields: [productOwnerUserId], references: [id], onDelete: Restrict)
712741
742+
mentorUserId String?
743+
mentorUser User? @relation("ProgramBProjectMentor", fields: [mentorUserId], references: [id], onDelete: SetNull)
744+
745+
mentorAssignedAt DateTime?
746+
mentorAssignedById String?
747+
mentorAssignedBy User? @relation("ProgramBProjectMentorAssignedBy", fields: [mentorAssignedById], references: [id], onDelete: SetNull)
748+
713749
status ProgramBProjectStatus @default(ACTIVE)
714750
715751
acceptedByCompanyAt DateTime?
@@ -721,12 +757,15 @@ model ProgramBProject {
721757
milestones ProgramBMilestone[]
722758
mentoringNotes ProgramBMentoringNote[]
723759
poReviews ProgramBPoReview[]
760+
documents ProgramBProjectDocument[]
724761
725762
@@index([teamId])
726763
@@index([backlogItemId])
727764
@@index([applicationId])
728765
@@index([teamApplicationId])
729766
@@index([productOwnerUserId])
767+
@@index([mentorUserId])
768+
@@index([mentorAssignedById])
730769
@@index([status])
731770
}
732771

@@ -748,6 +787,54 @@ model ProgramBMilestone {
748787
@@index([projectId, status])
749788
}
750789

790+
model ProgramBBacklogDocument {
791+
id String @id @default(uuid())
792+
793+
backlogItemId String
794+
backlogItem BacklogItem @relation(fields: [backlogItemId], references: [id], onDelete: Cascade)
795+
796+
uploadedFileId String
797+
uploadedFile UploadedFile @relation(fields: [uploadedFileId], references: [id], onDelete: Cascade)
798+
799+
category ProgramBBacklogDocumentCategory
800+
visibility ProgramBDocumentVisibility @default(PARTICIPANTS)
801+
version Int @default(1)
802+
isActive Boolean @default(true)
803+
804+
createdById String
805+
createdBy User @relation(fields: [createdById], references: [id], onDelete: Restrict)
806+
807+
createdAt DateTime @default(now())
808+
updatedAt DateTime @updatedAt
809+
810+
@@index([backlogItemId, category, isActive])
811+
@@index([uploadedFileId])
812+
}
813+
814+
model ProgramBProjectDocument {
815+
id String @id @default(uuid())
816+
817+
projectId String
818+
project ProgramBProject @relation(fields: [projectId], references: [id], onDelete: Cascade)
819+
820+
uploadedFileId String
821+
uploadedFile UploadedFile @relation(fields: [uploadedFileId], references: [id], onDelete: Cascade)
822+
823+
category ProgramBProjectDocumentCategory
824+
visibility ProgramBDocumentVisibility @default(PARTICIPANTS)
825+
version Int @default(1)
826+
isActive Boolean @default(true)
827+
828+
createdById String
829+
createdBy User @relation(fields: [createdById], references: [id], onDelete: Restrict)
830+
831+
createdAt DateTime @default(now())
832+
updatedAt DateTime @updatedAt
833+
834+
@@index([projectId, category, isActive])
835+
@@index([uploadedFileId])
836+
}
837+
751838
model ProgramBMentoringNote {
752839
id String @id @default(uuid())
753840
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ApiPropertyOptional } from '@nestjs/swagger';
2+
import { IsInt, IsOptional, IsString, MaxLength, Min } from 'class-validator';
3+
4+
export class CompleteProgramBDocumentUploadDto {
5+
@ApiPropertyOptional()
6+
@IsOptional()
7+
@IsInt()
8+
@Min(1)
9+
size?: number;
10+
11+
@ApiPropertyOptional()
12+
@IsOptional()
13+
@IsString()
14+
@MaxLength(255)
15+
checksum?: string;
16+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
2+
import {
3+
ProgramBBacklogDocumentCategory,
4+
ProgramBDocumentVisibility,
5+
} from 'generated/prisma/enums';
6+
import {
7+
IsEnum,
8+
IsInt,
9+
IsMimeType,
10+
IsOptional,
11+
IsString,
12+
MaxLength,
13+
Min,
14+
} from 'class-validator';
15+
16+
export class CreateProgramBBacklogDocumentUploadDto {
17+
@ApiProperty()
18+
@IsString()
19+
@MaxLength(255)
20+
filename!: string;
21+
22+
@ApiProperty()
23+
@IsMimeType()
24+
mimeType!: string;
25+
26+
@ApiProperty()
27+
@IsInt()
28+
@Min(1)
29+
size!: number;
30+
31+
@ApiProperty({
32+
enum: ProgramBBacklogDocumentCategory,
33+
example: ProgramBBacklogDocumentCategory.TECHNICAL_SPECIFICATION,
34+
})
35+
@IsEnum(ProgramBBacklogDocumentCategory)
36+
category!: ProgramBBacklogDocumentCategory;
37+
38+
@ApiPropertyOptional({
39+
enum: ProgramBDocumentVisibility,
40+
example: ProgramBDocumentVisibility.PARTICIPANTS,
41+
})
42+
@IsOptional()
43+
@IsEnum(ProgramBDocumentVisibility)
44+
visibility?: ProgramBDocumentVisibility;
45+
}

0 commit comments

Comments
 (0)