Monorepo for Tangled tangled.org

appview/db: allow regenerating invite codes

users sometimes want to regenerate invite codes, but signups_inflight
never replaces the old value, since the email column has a unique
constraint. by using `or replace`, we can update the invite code.

this keeps the db in sync with whatever the user sees in their inbox.

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li 9d600a67 8817c3ca

verified
+1 -1
+1 -1
appview/db/signup.go
··· 5 ) 6 7 func AddInflightSignup(e Execer, signup models.InflightSignup) error { 8 - query := `insert into signups_inflight (email, invite_code) values (?, ?)` 9 _, err := e.Exec(query, signup.Email, signup.InviteCode) 10 return err 11 }
··· 5 ) 6 7 func AddInflightSignup(e Execer, signup models.InflightSignup) error { 8 + query := `insert or replace into signups_inflight (email, invite_code) values (?, ?)` 9 _, err := e.Exec(query, signup.Email, signup.InviteCode) 10 return err 11 }