diff --git a/apps/api/src/controllers/admin/manage/manage-users-controller.ts b/apps/api/src/controllers/admin/manage/manage-users-controller.ts index 63fca9c90..ace455883 100644 --- a/apps/api/src/controllers/admin/manage/manage-users-controller.ts +++ b/apps/api/src/controllers/admin/manage/manage-users-controller.ts @@ -143,6 +143,24 @@ export class ManageUsersController { @BodyParams("userIds", String) userIds: string[], @BodyParams("days", Number) days = 30, ) { + await prisma.petMedicalRecord.deleteMany({ + where: { + pet: { + citizen: { + userId: { in: userIds }, + }, + }, + }, + }); + + await prisma.pet.deleteMany({ + where: { + citizen: { + userId: { in: userIds }, + }, + }, + }); + const arr = await prisma.$transaction( userIds.map((id) => prisma.user.deleteMany({ @@ -472,6 +490,24 @@ export class ManageUsersController { throw new NotFound("notFound"); } + await prisma.petMedicalRecord.deleteMany({ + where: { + pet: { + citizen: { + userId: user.id, + }, + }, + }, + }); + + await prisma.pet.deleteMany({ + where: { + citizen: { + userId: user.id, + }, + }, + }); + await prisma.user.delete({ where: { id: user.id,