-- 同一分公司内手机号唯一(数字归一化);全局仍允许重复。 -- 空手机号、无分公司(如超管)不纳入本约束。 CREATE UNIQUE INDEX IF NOT EXISTS profiles_phone_digits_branch_uidx ON public.profiles ( regexp_replace(COALESCE(phone, ''), '[^0-9]', '', 'g'), branch_code ) WHERE regexp_replace(COALESCE(phone, ''), '[^0-9]', '', 'g') <> '' AND branch_code IS NOT NULL;