fix(db): truncate downstream tables before services dedup to avoid FK violation (#197)
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: groombook-engineer[bot] <3141748+groombook-engineer[bot]@users.noreply.github.com> Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit was merged in pull request #197.
This commit is contained in:
committed by
GitHub
parent
1c99af07ce
commit
07263a89fe
@@ -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