Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Delete workspace invoices before project removal in delete cron (#3712)

Kiran K5d6fe0d72287
diff --git a/apps/web/app/(ee)/api/cron/workspaces/delete/delete-workspace.ts b/apps/web/app/(ee)/api/cron/workspaces/delete/delete-workspace.ts
index a24e3766a4..5e28278324 100644
--- a/apps/web/app/(ee)/api/cron/workspaces/delete/delete-workspace.ts
+++ b/apps/web/app/(ee)/api/cron/workspaces/delete/delete-workspace.ts
@@ -5,6 +5,19 @@ import { DeleteWorkspacePayload } from "./utils";
export async function deleteWorkspace(payload: DeleteWorkspacePayload) {
const { workspaceId } = payload;
+ // Delete invoices
+ const deletedInvoices = await prisma.invoice.deleteMany({
+ where: {
+ workspaceId,
+ },
+ });
+
+ if (deletedInvoices.count > 0) {
+ console.log(
+ `Deleted ${deletedInvoices.count} invoices for workspace ${workspaceId}.`,
+ );
+ }
+
const workspace = await prisma.project.findUnique({
where: {
id: workspaceId,