Bernt Christian Egeland 1 месяц назад
Родитель
Сommit
11db025938
1 измененных файлов с 7 добавлено и 0 удалено
  1. 7 0
      prisma/seed_dummy_data.ts

+ 7 - 0
prisma/seed_dummy_data.ts

@@ -146,6 +146,13 @@ async function provisionDemoAccount() {
   // foreign organizations so the reset always converges on a single org.
   // Org-scoped rows go with them via ON DELETE CASCADE, and stale
   // active-org cookies fall back to the demo org membership.
+  // inspections.templateId is ON DELETE RESTRICT, so the cascade cannot
+  // resolve templates and inspections in one statement; clear inspections
+  // first. (The only other RESTRICT in the schema, subscriptions.planId,
+  // guards global plans the purge never deletes.)
+  await prisma.inspection.deleteMany({
+    where: { organizationId: { not: ORG_ID } },
+  });
   const foreignOrgs = await prisma.organization.deleteMany({
     where: { id: { not: ORG_ID } },
   });