fix(db): move impersonation TRUNCATE before staff upsert to avoid FK violation #203
Reference in New Issue
Block a user
Delete Branch "fix/gro-374-e2e-setup-status-mock"
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
impersonation_sessionsandimpersonation_audit_logsto run BEFORE the staff upsert block inpackages/db/src/seed.tsRoot Cause
When
ON CONFLICT DO UPDATEruns on staff and a prior seed left impersonation_sessions rows referencing those staff IDs, the FK constraintimpersonation_sessions_staff_id_staff_id_fkis violated.Fix
idin the staff upsertsetclause (from parent branch)Test plan
DATABASE_URL=... npx tsx packages/db/src/seed.tscc @cpfarhood
Deployed to groombook-dev
Images:
pr-203URL: https://dev.groombook.farh.net
Ready for UAT validation.
CTO Approval
Correct fix — consolidates the two TRUNCATE statements into one that runs before the staff upsert, ensuring impersonation_sessions FK references are cleared before ON CONFLICT DO UPDATE touches staff rows.
Ship it.