-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (25 loc) · 728 Bytes
/
index.js
File metadata and controls
27 lines (25 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export async function onDelete({ prisma, projectId, logger }) {
try {
const board = await prisma.papertrailBoard.findUnique({
where: { projectId },
select: { id: true },
});
if (!board) {
return;
}
await prisma.$transaction([
prisma.papertrailNode.deleteMany({ where: { boardId: board.id } }),
prisma.papertrailEdge.deleteMany({ where: { boardId: board.id } }),
prisma.papertrailBoard.delete({ where: { id: board.id } }),
]);
} catch (err) {
if (err?.code === "P2025") {
// Not found; ignore
return;
}
if (logger?.error) {
logger.error("[papertrail] onDelete failed", { projectId, error: err?.message });
}
throw err;
}
}