zhangwenjian
4911730012
fix 🐛 : give the natural keys a constraint the database can keep
...
sys_user.username, sys_role.role_key and sys_dict_type.dict_type had no
unique index. Uniqueness was a SELECT COUNT followed by an INSERT, which
two concurrent requests both pass — and login resolves a username with
First, so which of the two accounts answers is whichever the database
returns.
The index cannot be on the key alone, because a soft-deleted row keeps
occupying the name and a deleted user's username could never be used
again. It has to include the delete marker, and the marker has to be
non-null: two live rows are (alice, NULL) and (alice, NULL), and NULL is
not equal to NULL, so an index over a nullable marker admits both. That
is the worst of the three states — a constraint that reads as protection
and binds nothing — and there is a test that demonstrates it rather than
asserting it.
ModelTime.DeletedAt is milliseconds since the epoch now, zero while the
row is live. Sixteen tables carry it; the migration converts each one,
preserving when each deleted row was deleted, then adds the three
indexes.
Written to be re-runnable rather than transactional, because DDL does not
roll back on MySQL and an operator whose first attempt failed halfway
should have nothing to do but run it again. It refuses before altering
anything if a table already holds duplicates, naming them, rather than
letting the index fail and leaving the operator to guess.
The timestamp conversion happens in Go: turning a timestamp into epoch
milliseconds is spelled differently by every dialect this supports, and
these row counts do not justify four versions of it.
2026-08-22 11:27:22 +08:00
zhangwenjian
b81611ba72
chore 🔧 : 清理 refresh_token 的残留权限数据
...
接口移除后,库中仍留有三类记录:sys_api 的接口登记、sys_menu_api_rule 的
菜单绑定、casbin_rule 的策略。留着会让「接口管理」列出一个不存在的端点,
角色配置里也仍可勾选。
- 新装:从 db.sql 与 db-sqlserver.sql 的种子数据中删除该接口
- 已有部署:新增迁移清理,按 path 匹配而非固定 id,因为执行过
`server -a` 重新注册接口的库中 id 会与官方种子数据不同
2026-08-14 21:42:59 +08:00
zhangwenjian
ed9450a2d5
feat ✨ : 补充 demo 模块的菜单与权限种子数据
...
一个业务模块要在界面上可用,需要四类数据协同:
sys_api 后端路由登记,Casbin 据此判定
sys_menu 侧边栏菜单,含目录 M、菜单 C、按钮 F 三级
sys_menu_api_rule 菜单与接口的关联,角色保存时据此生成策略
casbin_rule 实际生效的权限策略
菜单的 menu_name 与前端组件 name 保持一致(DemoProduct),按钮的
permission 与前端 v-permisaction 标识一致(demo:product:add 等)。
策略写入 casbin_rule 而非 sys_casbin_rule:后者对应的 models.CasbinRule
是历史遗留,其 7 列 size:512 唯一索引在 MySQL 下会超出索引长度限制,实际
生效的是 adapter 创建的 casbin_rule 表。
所有写入均为存在则更新、不存在则插入,迁移可安全地在已有数据的库上执行。
实测:在含 67 条菜单、121 条接口的库上执行后各表数据正确;清除版本记录重
跑一次,各表行数不变,确认幂等。
2026-08-14 16:57:55 +08:00
zhangwenjian
4d7c9e5a12
feat ✨ : 补充 demo 模块的建表迁移
...
放在 version/ 而非 version-local/:后者已被 .gitignore 忽略,是留给使用
者存放自身迁移脚本的位置,示例迁移需随框架一起分发。文件注释中说明了这
一区分。
2026-08-14 16:46:53 +08:00
wenjianzhang
37a5963cd6
perf 👌 : Optimize go warnings
2023-08-01 22:38:41 +08:00
wenjianzhang
7d1b84e837
Merge pull request #706 from haimait/master-test
...
1. 修复日志创建时间筛选报错的bug.
2022-09-05 19:58:06 +08:00
wanghaima
0f742900f5
1. 修复日志创建时间筛选报错的bug.
...
2. 修复日志里操作人,修改人,userAgent为空的bug.
3. 迁移表时,日志表添加字段注释.
4. sys_opera_log表oper_param字段类型改为text,解决字段长度报错的问题
2022-09-04 10:02:26 +08:00
infnan
0993173b1f
处理postgre启动报错问题
...
Signed-off-by: infnan <38274826+infnan@users.noreply.github.com >
2022-08-18 16:50:54 +08:00
zhangwenjian
869394c898
perf 👌 : Remove caspin table from data migration
2022-08-09 18:21:00 +08:00
zhangwenjian
289fbba8e0
perf 👌 : update casbin gorm adapter
2022-08-09 18:17:06 +08:00
zhangwenjian
a6ffac657e
fix 🐛 : Add MySQL judgment in data migration
2022-08-09 15:20:45 +08:00
zhangwenjian
0d47fb4e68
Merge branch 'master' of github.com:go-admin-team/go-admin
2022-08-08 16:28:34 +08:00
zhangwenjian
8bfee8af16
refactor 🎨 : 添加菜单paths默认数据
2022-08-08 16:28:26 +08:00
Vingurzhou
9a596397ca
Update 1599190683659_tables.go
2022-08-08 11:28:55 +08:00
zhangwenjian
1bea64bb6d
config 🔧 : set DB CHARSET utf8mb4( #674 )
2022-08-08 10:16:43 +08:00
zhangwenjian
09bfdc3d39
config 🔧 : set DB CHARSET utf8mb4
2022-08-08 10:15:29 +08:00
wenjianzhang
50f14f7658
Merge branch 'dev' into wkf928592-patch-1
2022-06-05 10:36:20 +08:00
kaiyuan
eb33515e29
throw error if migrate failed
2022-04-08 10:32:07 +08:00
wenjianzhang
d02b52f383
feat ✨ : 添加sqlserver支持
2022-02-08 18:41:09 +08:00
zhangwenjian
24908a8732
refactor 🎨 : 添加error判断返回
2022-01-22 23:03:01 +08:00
wenjianzhang
0b73bd7b25
refactor 🎨 : 修改sqplite的支持
2022-01-22 19:37:56 +08:00
wenjianzhang
443c30d48c
Update 1599190683659_tables.go
2021-10-22 12:05:39 +08:00
wkf928592
ce9d9bd3ec
fix:在32位系统中做迁移时,版本号作为整型处理会造成内存溢出的问题
...
修改版本号作为字符串处理
2021-09-10 10:19:33 +08:00
zhangwenjian
b6be297a1e
refactor 🎨 : 添加默认demo代码生成表
2021-07-04 13:43:32 +08:00
zhangwenjian
a6116ede02
refactor 🎨 : 修改字典类型status为int
2021-06-20 00:39:43 +08:00
zhangwenjian
b97b3bc6d8
refactor 🎨 :部门创建添加事务,已经修改status字段为int类型
2021-06-20 00:14:45 +08:00
zhangwenjian
25472887c9
refactor 🎨 :移除内容管理、行政区管理和资源管理
2021-06-18 21:34:57 +08:00
zhangwenjian
493d714723
refactor 🎨 :修改行政区数据sql
2021-06-17 21:46:19 +08:00
zhangwenjian
a911e73238
refactor 🎨 :调整行政区命名
2021-06-17 21:45:37 +08:00
zhangwenjian
185df737c8
refactor 🎨 :调整管理员和字典相关结构体字段顺序
2021-06-17 21:10:12 +08:00
wenjianzhang
13f09d6059
refactor 🎨 :数据迁移结构体重命名
2021-06-15 19:02:57 +08:00
wenjianzhang
1c9d2075d7
refactor 🎨 :调整接口和行政区结构体
2021-06-15 17:54:46 +08:00
wenjianzhang
3a688c06a1
refactor 🎨 :初始化脚本针对关键字添加引号
2021-06-15 17:54:04 +08:00
wenjianzhang
af7a3e99a8
efactor 🎨 :修改行政区域数据结构
...
主键不需要自增
2021-06-15 12:22:30 +08:00
wenjianzhang
992d892523
refactor 🎨 :补充初始化数据
2021-06-15 12:16:44 +08:00
wenjianzhang
52f45e362b
Merge branch 'dev' of github.com:go-admin-team/go-admin into dev
2021-06-11 15:26:41 +08:00
wenjianzhang
1391366ece
refactor 🎨 : 添加行政区模型
2021-06-11 15:26:35 +08:00
zhangwenjian
24c78519ed
refactor 🎨 : 数据迁移模型调整
2021-06-10 11:24:35 +08:00
zhangwenjian
352224b994
refactor 🎨 : 修改数据迁移脚本
2021-06-10 11:22:23 +08:00
wenjianzhang
54e116818b
refactor 🎨 : 数据初始化
2021-06-09 18:30:47 +08:00
wenjianzhang
6a31ac916a
refactor 🎨 : 移除v1版本中的数据迁移脚本
2021-06-09 18:25:00 +08:00
zhangwenjian
a54d4ba0c1
format 🥚 代码格式化
2021-05-31 18:10:23 +08:00
wenjianzhang
dfd460c50b
feat ✨ apis路径简化
2021-05-14 12:19:22 +08:00
wenjianzhang
8adc79a5f7
feat ✨ 新增省市区基础数据
2021-05-13 08:45:27 +08:00
wenjianzhang
ee15329bd2
feat ✨ systables 数据迁移模块更新
2021-05-11 18:53:40 +08:00
wenjianzhang
cd29c1728d
refactor 🎨 删除模版生成提示代码
2021-05-10 18:23:41 +08:00
linwenxiang
bf7934c20a
fix 🐛 优化迁移功能
2021-04-26 14:47:31 +08:00
linwenxiang
845558cc65
fix 🐛 修复初始化数据库账号登录不了问题
2021-04-26 10:45:45 +08:00
linwenxiang
1a111f0666
migrate ✅ 优化migrate
2021-04-23 14:25:31 +08:00
wenjianzhang
547a5eb8e4
fix 🐛 :修复初始化Duplicate column name 'is_frontend' ( #376 )
2021-03-25 18:35:09 +08:00