Files
team-api/migrations/000010_v0_1_12_version.sql
Qianandqian 501726b831 优化用户相关功能 (#8)
* improve(user):优化注册功能提示

* improve(user):优化邮箱大小写重复问题

* improve(user):添加密码强度指示器

* fix(setting):修复系统设置功能里面的数字转换问题

* feat(email):优化邮件发送功能

* chore(email):移除无用配置和日志

* fix(user):修复重置密码功能

* chore(ui):调整轮询间隔

* chore(ui):添加充值提示

* chore(ui):优化用户注册功能

* chore(sql):补充数据库变更文件

* fix(email):优化邮箱校验

---------

Co-authored-by: qian <wuchengqian5@163.com>
2026-06-17 22:47:26 +08:00

26 lines
1.5 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- +goose Up
-- 将 tnt_users.email 由 NOT NULL 改为可空。
--
-- 背景:普通成员的邮箱在系统中基本用不上——成员只能用 RAM 账号(username@tenant_code)
-- 登录(admin 邮箱登录只认 role=owner 的主用户),且成员不能凭邮箱自助重置密码,
-- 邮箱仅用于邮件通知与成员列表展示。因此将邀请加入、管理员创建、CSV 导入三条
-- 创建路径统一为「邮箱选填」,与 CreateMember / member_import 既有的选填行为对齐。
--
-- 顺带修复既有隐患:原 email 为 NOT NULL + UNIQUE(tenant_id, email),不填邮箱时
-- 代码只能写入空字符串 "",而空字符串是确定值,导致同一租户下仅能存在一个空邮箱
-- 成员,第二个会撞唯一约束报「邮箱已存在」。改为可空后,PostgreSQL 唯一索引允许
-- 多个 NULL,多个无邮箱成员不再冲突。
--
-- 注意:列的可空性变更不需要重新 gf gen dao——DO 中 Email 字段本就声明为 any 类型,
-- 业务代码在 email 为空时传 nil 即可写入 SQL NULL。
ALTER TABLE tnt_users ALTER COLUMN email DROP NOT NULL;
-- 将已存在的空字符串 email 归一为 NULL,避免旧空串数据继续占用唯一约束位。
UPDATE tnt_users SET email = NULL WHERE email = '';
-- +goose Down
-- 恢复 NOT NULL 前需保证无 NULL email(否则 SET NOT NULL 会失败),回退为空字符串。
UPDATE tnt_users SET email = '' WHERE email IS NULL;
ALTER TABLE tnt_users ALTER COLUMN email SET NOT NULL;