Safer “find or create” with Unique Constraint + Retry

11459
0

Race conditions happen. The correct “find or create” in production uses a unique constraint and a retry on conflict, not a naive check-then-insert. Let the database serialize the race.