Keep issues when assignee or reporter is deleted

Switch issue.assigneeId/reporterId FKs from CASCADE to SET NULL and make
reporter nullable through the entity, DTOs and GraphQL types.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vadimandClaude Opus 5.5 committed 2026-10-01 11:23:51 +03:00
1 parent 4b8c855855
commit 2696f33a7e
8 files changed
+31 -21

No files matched your search

@@ -8,9 +8,9 @@ export class IssueWithUsersDto {
status: string;
priority: number;
assigneeId: string | null;
reporterId: string;
reporterId: string | null;
assignee: UserDto | null;
reporter: UserDto;
reporter: UserDto | null;
projectId: string;
dueDate: Date | null;
createdAt: Date;
@@ -6,7 +6,7 @@ export class IssueDto {
status: string;
priority: number;
assigneeId: string | null;
reporterId: string;
reporterId: string | null;
projectId: string;
dueDate: Date | null;
createdAt: Date;
@@ -23,11 +23,6 @@ export class IssueApplicationMapper {
/** Раскрывает assignee/reporter в полноценных пользователей (см. GetIssueUseCase) */
static toDtoWithUsers(issue: Issue, usersById: ReadonlyMap<string, UserDto>): IssueWithUsersDto {
const reporter = usersById.get(issue.reporter);
if (!reporter) {
throw new Error(`Reporter user ${issue.reporter} not found for issue ${issue.key}`);
}
return {
id: issue.id as number,
key: issue.key,
@@ -38,7 +33,7 @@ export class IssueApplicationMapper {
assigneeId: issue.assignee,
reporterId: issue.reporter,
assignee: issue.assignee ? (usersById.get(issue.assignee) ?? null) : null,
reporter,
reporter: issue.reporter ? (usersById.get(issue.reporter) ?? null) : null,
projectId: issue.projectId,
dueDate: issue.dueDate,
createdAt: issue.createdAt,