fix(db): idempotent services seed — no more duplicate services #185
Reference in New Issue
Block a user
Delete Branch "fix/gro-301-duplicate-services"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
seedKnownUsers()(used byPOST /api/admin/seed) inserted demo services withdefaultRandom()UUIDs and no idempotency guard. The main CLI seed uses deterministic IDs +ON CONFLICT DO UPDATEonid, so running seeds in any order or repetition created duplicate service rows.a0000001-0000-0000-0000-000000000001…004) withON CONFLICT DO UPDATEonid, matching the pattern already applied toclientsin40143c4.Changes
packages/db/src/seed.ts— replace naive existence check + random-UUID INSERT with deterministic-ID upsertapps/api/src/routes/admin/seed.ts— same fix for the admin API seed endpointTest plan
services/admin/servicesand/admin/bookshow each service exactly once🤖 Generated with Claude Code
Summary
Fixed the duplicate services bug in both seed paths by using deterministic UUIDs +
ON CONFLICT DO UPDATEonid.cc @cpfarhood
Parent issue: GRO-299
This issue: GRO-301
Deployed to groombook-dev
Images:
pr-185URL: https://dev.groombook.farh.net
Ready for UAT validation.
CTO Code Review — PR #185
Assessment: Code is correct ✓
The fix replaces the "skip if any service exists" seed logic with idempotent upserts using deterministic UUIDs and
onConflictDoUpdate. This is the right approach:a0000001-...) ensure re-seeds update rather than duplicateonConflictDoUpdateonservices.idis clean Drizzle ORM usageapps/api/src/routes/admin/seed.tsandpackages/db/src/seed.ts)⚠️ Note: Overlapping changes with PR #186
PR #186 includes identical seed changes plus the reports UTC fix. These two PRs will conflict when one merges. Recommendation: merge one, rebase the other.
QA Test Steps
/admin→ check services in the booking flow or admin panel/api/admin/seedagain → verify still exactly 4 services (no duplicates created)Awaiting QA review before formal CTO approval.
Deployed to groombook-dev
Images:
pr-185URL: https://dev.groombook.farh.net
Ready for UAT validation.
CTO Approval
Idempotent services seed fix is correct. Deterministic UUIDs, proper onConflictDoUpdate, dedup cleanup. All CI green.
cc @cpfarhood
Deployed to groombook-dev
Images:
pr-185URL: https://dev.groombook.farh.net
Ready for UAT validation.
QA Approval — PR #185 ✅
Tester: Lint Roller
CI Verification
All CI checks green:
Code Review
The fix correctly addresses the duplicate services bug:
Files Changed
Recommendation
APPROVE — Fix is correct, CI is green. Ready for merge.
cc @cpfarhood
Deployed to groombook-dev
Images:
pr-185URL: https://dev.groombook.farh.net
Ready for UAT validation.