Simplify Project Schema — Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Remove budget/deadline fields from the Project model and simplify project creation to title + description + optional category.
Architecture: Prisma schema change → DTO update → service update → migration. No controller changes needed — endpoints stay the same, just with fewer fields.
Tech Stack: Prisma, NestJS, class-validator, class-transformer
Task 1: Update Prisma Schema
Заголовок раздела «Task 1: Update Prisma Schema»Files:
- Modify:
apps/core-api/prisma/schema.prisma:550-553(remove ProjectBudgetType enum) - Modify:
apps/core-api/prisma/schema.prisma:608-631(simplify Project model)
Step 1: Remove ProjectBudgetType enum
Delete these lines (550-553):
enum ProjectBudgetType { FIXED HOURLY}Step 2: Simplify Project model
Replace the current Project model (lines 608-631) with:
model Project { id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid title String description String category ProjectCategoryType? status ProjectStatus @default(DRAFT) customerId String @map("customer_id") @db.Uuid
createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at")
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade) walriderThread WalriderThread?
@@index([customerId]) @@index([status]) @@index([category]) @@map("projects")}Changes from original:
- Removed:
budgetType,budgetMin,budgetMax,currency,deadline - Changed:
categoryfromProjectCategoryTypetoProjectCategoryType?(nullable)
Step 3: Commit
git add apps/core-api/prisma/schema.prismagit commit -m "refactor(schema): remove budget/deadline fields from Project, make category optional"Task 2: Update DTOs
Заголовок раздела «Task 2: Update DTOs»Files:
- Modify:
libs/apis/providers/project-api/data-access/src/lib/dtos/project.dto.ts
Step 1: Rewrite project.dto.ts
Replace the entire file content with:
import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger';import { Expose, Type } from 'class-transformer';import { IsDate, IsEnum, IsInt, IsOptional, IsString, IsUUID, MaxLength, Min, MinLength,} from 'class-validator';import { Trim } from '@crewsforge-back/apis/shared';import { ProjectCategoryType, ProjectStatus } from '@prisma/client';
// --- Base ---
export class ProjectDto { @ApiProperty() @Expose() @IsUUID() id!: string;
@ApiProperty() @Expose() @IsString() @MinLength(3) @MaxLength(255) @Trim() title!: string;
@ApiProperty() @Expose() @IsString() @MinLength(3) @Trim() description!: string;
@ApiProperty({ enum: ProjectCategoryType, required: false }) @Expose() @IsOptional() @IsEnum(ProjectCategoryType) category?: ProjectCategoryType | null;
@ApiProperty({ enum: ProjectStatus }) @Expose() @IsEnum(ProjectStatus) status!: ProjectStatus;
@ApiProperty() @Expose() @IsUUID() customerId!: string;
@ApiProperty() @Expose() @IsDate() createdAt!: Date;
@ApiProperty() @Expose() @IsDate() updatedAt!: Date;}
const excludeBaseField = ['id', 'createdAt', 'updatedAt'] as const;
// --- Response ---
export class ProjectResponseDto extends ProjectDto {}
// --- Create ---
export class ProjectCreateDto extends OmitType(ProjectDto, [ ...excludeBaseField, 'status', 'customerId',]) {}
// --- Update (only DRAFT) ---
export class ProjectUpdateDto extends PartialType( OmitType(ProjectDto, [...excludeBaseField, 'status', 'customerId'])) {}
// --- Update Status ---
export class ProjectUpdateStatusDto { @ApiProperty({ enum: ProjectStatus }) @Expose() @IsEnum(ProjectStatus) status!: ProjectStatus;}
// --- List Query ---
export class ProjectListQueryDto { @ApiProperty({ enum: ProjectStatus, required: false }) @Expose() @IsOptional() @IsEnum(ProjectStatus) status?: ProjectStatus;
@ApiProperty({ default: 1, required: false }) @Expose() @IsOptional() @IsInt() @Min(1) @Type(() => Number) page?: number;
@ApiProperty({ default: 10, required: false }) @Expose() @IsOptional() @IsInt() @Min(1) @Type(() => Number) perPage?: number;}Key changes:
- Removed imports:
IsDecimal,ProjectBudgetType - Removed fields:
budgetType,budgetMin,budgetMax,currency,deadline - Changed
descriptionmin length from 10 to 3 - Changed
categoryto optional with?and| null
Step 2: Commit
git add libs/apis/providers/project-api/data-access/src/lib/dtos/project.dto.tsgit commit -m "refactor(dto): simplify ProjectDto - remove budget/deadline fields, make category optional"Task 3: Update Project Service
Заголовок раздела «Task 3: Update Project Service»Files:
- Modify:
libs/apis/providers/project-api/features/project/src/lib/project.service.ts
Step 1: Simplify create method
Replace the create method’s data construction (lines 24-34) with:
const data: Prisma.ProjectCreateInput = { title: dto.title, description: dto.description, category: dto.category ?? undefined, customer: { connect: { id: customerId } }, };Step 2: Simplify updateOneById method
Replace the data spread in updateOneById (lines 89-98) with:
data: { ...(dto.title !== undefined && { title: dto.title }), ...(dto.description !== undefined && { description: dto.description }), ...(dto.category !== undefined && { category: dto.category }), },Step 3: Commit
git add libs/apis/providers/project-api/features/project/src/lib/project.service.tsgit commit -m "refactor(service): remove budget/deadline handling from ProjectService"Task 4: Generate and Run Prisma Migration
Заголовок раздела «Task 4: Generate and Run Prisma Migration»Step 1: Generate migration
cd apps/core-apinpx prisma migrate dev --name remove_budget_deadline_from_projectThis will generate a migration that:
- Drops columns:
budget_type,budget_min,budget_max,currency,deadline - Alters
categoryto be nullable - Drops the
ProjectBudgetTypeenum type
Step 2: Verify migration SQL
Check the generated migration file to confirm it contains the expected ALTER TABLE statements.
Step 3: Generate Prisma client
npx prisma generateStep 4: Commit
git add apps/core-api/prisma/migrations/git commit -m "migration: remove budget/deadline columns from projects table"Task 5: Build Verification
Заголовок раздела «Task 5: Build Verification»Step 1: Build the project
npx nx build core-apiExpected: Clean build, no TypeScript errors.
Step 2: If build fails
Check for any remaining references to removed fields (budgetType, budgetMin, budgetMax, currency, deadline, ProjectBudgetType) and fix them.
Step 3: Commit any fixes
git add -Agit commit -m "fix: resolve build errors from schema simplification"