postgresql DB

Stores `users` rows and applies invite-code state transitions inside the registration tx.

Function I/O

NameInOutSidePurpose
SELECT_invite_for_updatecodeInviteCodeRow | nillockLocks the invite row for the duration of the transaction.
INSERT_usersuserRowuserIdwritePersists the new account.
UPDATE_invite_consumedcode, nowrows_affectedwriteMarks the invite as consumed.

Variables

NameTypeScopePurpose
users.emailtextpersistUnique account identity.
invite_codes.consumed_attimestamptzpersistTimestamp set the moment the invite row is consumed.

Internal data flow

1 Apply row lock on invite_codes. 2 Validate uniqueness of users.email. 3 Write users row and update invite_codes.consumed_at.

Errors

NameWhenMeans
ErrUniqueEmailusers.email unique constraint violated.Bubble up so service can return ErrEmailTaken.