fix(db): truncate downstream tables before services dedup to avoid FK violation

TRUNCATE appointments, invoices, invoice_line_items, invoice_tip_splits,
and grooming_visit_logs CASCADE before the services dedup DELETE to prevent
FK violations from appointments created by previous seed runs.

Fixes: GRO-365

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
groombook-engineer[bot]
2026-04-01 13:10:58 +00:00
parent 1c99af07ce
commit 7fb5ddbbd1
+3
View File
@@ -423,6 +423,9 @@ async function seed() {
}
console.log(`✓ Created ${allStaff.length} staff (1 manager, 1 receptionist, 3 groomers, 3 bathers)`);
// Truncate downstream tables before services dedup to avoid FK violation
await db.execute(sql`TRUNCATE appointments, invoices, invoice_line_items, invoice_tip_splits, grooming_visit_logs CASCADE`);
// ── Services ──
// Deduplicate existing services (keep lowest id per name) before inserting.
await db.execute(sql`