fix(db): move impersonation TRUNCATE before staff upsert to avoid FK violation #203

Merged
groombook-engineer[bot] merged 1 commits from fix/gro-374-e2e-setup-status-mock into main 2026-04-02 01:03:36 +00:00

1 Commits

Author SHA1 Message Date
groombook-engineer[bot] 69c9c7d117 fix(db): move impersonation TRUNCATE before staff upsert to avoid FK violation
The TRUNCATE of impersonation_sessions/audit_logs was running after the
staff upsert. When a prior seed left impersonation_sessions rows
referencing staff records, ON CONFLICT DO UPDATE on staff violated the
FK constraint on impersonation_sessions.staff_id.

Moving the TRUNCATE before the staff block ensures all impersonation rows
are cleared before any staff insert/update attempt.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-02 00:42:25 +00:00