fix for phone generation on email signup

This commit is contained in:
onysd 2026-07-14 00:30:52 +03:00
parent cee960fea0
commit 3409f190b9
20 changed files with 457 additions and 54 deletions

View file

@ -0,0 +1,2 @@
DROP INDEX IF EXISTS users_signup_email_lower_unique_idx;
ALTER TABLE public.users DROP COLUMN signup_email;

View file

@ -0,0 +1,13 @@
-- Email-signup accounts (see internal/domain.EncodeEmailPhone) now get a
-- short, normal-looking random "888" phone number in users.phone instead of
-- storing the email-derived string there directly (that string only ever
-- travels on the wire during auth.sendCode/signIn/signUp, exactly like a real
-- phone number would). signup_email is the durable email->user reverse
-- lookup that replaces the old "phone IS the email encoding" identity: it is
-- what SendCode/SignIn use to find a returning email-signup account by the
-- (deterministic) wire value decoded back to an email.
ALTER TABLE public.users ADD COLUMN signup_email character varying(200) NOT NULL DEFAULT '';
-- Case-insensitive, ignores the empty default so real phone-number accounts
-- (the overwhelming majority) never touch this index.
CREATE UNIQUE INDEX users_signup_email_lower_unique_idx ON public.users (lower(signup_email)) WHERE signup_email <> '';