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,
@@ -12,7 +12,8 @@ interface IssueProps {
status: IssueStatus;
priority: IssuePriority;
assignee: string | null;
reporter: string;
/** null — автор задачи удалил аккаунт */
reporter: string | null;
projectId: string;
dueDate: Date | null;
createdAt: Date;
@@ -72,7 +73,7 @@ export class Issue {
status: string;
priority: number;
assignee: string | null;
reporter: string;
reporter: string | null;
projectId: string;
dueDate: Date | null;
createdAt: Date;
@@ -122,7 +123,7 @@ export class Issue {
return this.props.assignee;
}
get reporter(): string {
get reporter(): string | null {
return this.props.reporter;
}
@@ -24,14 +24,14 @@ export class IssueDetailType {
@Field(() => String, { nullable: true })
assigneeId: string | null;
@Field()
reporterId: string;
@Field(() => String, { nullable: true })
reporterId: string | null;
@Field(() => UserType, { nullable: true })
assignee: UserType | null;
@Field(() => UserType)
reporter: UserType;
@Field(() => UserType, { nullable: true })
reporter: UserType | null;
@Field()
projectId: string;
@@ -23,8 +23,8 @@ export class IssueType {
@Field(() => String, { nullable: true })
assigneeId: string | null;
@Field()
reporterId: string;
@Field(() => String, { nullable: true })
reporterId: string | null;
@Field()
projectId: string;