Email verification looks like a small feature until two requests arrive at nearly the same time. A user clicks “resend” while the first message is still being delivered, a worker retries after a timeout, or a browser submits the confirmation form twice. If the API and database do not share a clear contract, the result is an account that appears verified in one path and pending in another.
This post describes a PostgreSQL design for making verification state explicit. The same ideas apply when a backend uses a temp mail fixture in integration tests: the fixture should exercise the same state transitions and concurrency rules as production, not a simplified happy path.
Why verification state becomes inconsistent
Many implementations start with three columns: email , token , and verified . That model cannot explain enough events. A token can expire while a request is in flight. A resend can create a newer token, but an older message may still be clicked.…