Openstatus www.openstatus.dev

fix: update grouped monitors (#1539)

authored by

Maximilian Kaske and committed by
GitHub
e808de4f 1d89615b

+4 -3
+4 -3
packages/api/src/router/page.ts
··· 875 } 876 877 await opts.ctx.db.transaction(async (tx) => { 878 await tx 879 .delete(monitorGroup) 880 .where(eq(monitorGroup.pageId, opts.input.id)); 881 - await tx 882 - .delete(monitorsToPages) 883 - .where(eq(monitorsToPages.pageId, opts.input.id)); 884 885 if (opts.input.groups.length > 0) { 886 const monitorGroups = await tx
··· 875 } 876 877 await opts.ctx.db.transaction(async (tx) => { 878 + // Delete child records first to avoid foreign key constraint violation 879 + await tx 880 + .delete(monitorsToPages) 881 + .where(eq(monitorsToPages.pageId, opts.input.id)); 882 await tx 883 .delete(monitorGroup) 884 .where(eq(monitorGroup.pageId, opts.input.id)); 885 886 if (opts.input.groups.length > 0) { 887 const monitorGroups = await tx