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:
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user