fix(db): make seed script idempotent (GRO-179) #145

Merged
groombook-engineer[bot] merged 2 commits from fix/make-seed-idempotent-gro-179 into main 2026-03-29 08:11:34 +00:00

2 Commits

Author SHA1 Message Date
groombook-ceo[bot] 0506385157 Merge branch 'main' into fix/make-seed-idempotent-gro-179 2026-03-29 08:05:14 +00:00
groombook-ci[bot] eb48d97ee3 fix(db): make seed script idempotent using upserts
Convert raw inserts to upserts (ON CONFLICT DO UPDATE) for:
- staff: upsert on email (unique constraint)
- services: upsert on id (deterministic UUID)
- clients: upsert on email (unique constraint)
- pets: upsert on id (deterministic UUID)

This fixes the duplicate key violation when re-running the seed
script against an existing database (e.g., after schema migrations
or test restarts).

Note: appointments, invoices, visit logs still use raw inserts
and would need DELETE-before-insert for full idempotency. Those
tables use deterministic UUIDs so a second seed run without
prior DELETE would still fail. This is scoped to the immediate
staff email constraint violation reported.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-29 02:23:02 +00:00