Skip to content

Commit

Permalink
fix: delete user need delete joined private ns
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Sep 8, 2024
1 parent 0891510 commit a708e41
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions frontend/desktop/src/services/backend/cronjob/deleteUserCr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,30 @@ export class DeleteUserCrJob implements CronJobStatus {
})
}
});
await prisma.userWorkspace.deleteMany({
where: {
userCrUid: userCr.uid

await prisma.$transaction(async (prisma) => {
const privateWorkspace = await prisma.userWorkspace.findFirst({
where: {
userCrUid: userCr.uid,
isPrivate: true
},
select: {
workspaceUid: true
}
});
if (!privateWorkspace || !privateWorkspace.workspaceUid) {
throw new Error('Private workspace not found for the user.');
}
await prisma.userWorkspace.deleteMany({
where: {
workspaceUid: privateWorkspace.workspaceUid
}
});
await prisma.userWorkspace.deleteMany({
where: {
userCrUid: userCr.uid
}
});
});
}
canCommit() {
Expand Down

0 comments on commit a708e41

Please sign in to comment.