Skip to content

v2.7.0

Choose a tag to compare

@wenjianzhang wenjianzhang released this 27 Sep 10:40
· 37 commits to master since this release
c1d92ad

This release needs Go 1.27.1 and a migrate run, and the code generator now writes Vue 3 pages. Read the section below before upgrading.

⚠️ Before you upgrade

1. Build with Go 1.27.1 or later. Under Go 1.26.5, govulncheck reports 7 standard-library vulnerabilities reachable from this code; under 1.27.1 it reports none. go-admin-core v2.10.0 and later declare go 1.27.1. #948

2. Run migrate. Six migrations are new, 1786700005000 to 1786700010000, among them the application registry, the job scheduler's lease row and the generator's column layout fields. Until they are applied, the new /api/v1/ready answers 503 and names the database that is behind. On PostgreSQL, v2.6.0 stopped at 1786700003000, after which logins failed with unable to encode 0 into binary format for timestamptz; that migration is fixed here, so run migrate again. #921 #922

3. The code generator writes files only in dev and demo mode. Its three writing endpoints were open to any logged-in account. With application.mode set to test or prod, or not set, they are no longer registered. Generated pages are now Vue 3 and need go-admin-ui v3.3.0 or later. #917 #943 #951


  • 🔒 Security
    • 🔒 Any logged-in user could change another user's profile, role included, through PUT /api/v1/sys-user. #896
    • 🔒 Data permission failed open three ways: a database error let the request through unscoped, an unrecognised data_scope meant all data, and department id 0 matched every department. An unrecognised scope now matches nothing, and a migration sets such values, including the empty one the seed gave admin, to 1 (all data). #897 #904
    • 🔒 Demo mode let the code generator's writing endpoints through, because they are GET requests. #913
  • Deployment and shutdown
    • ✨ SIGTERM runs the graceful shutdown. Only SIGINT did, so docker stop, Kubernetes and systemd ended the process mid-request. #903
    • ✨ /api/v1/ready reports whether the database, cache and schema are usable, and fails from the moment shutdown starts. extend.shutdown.drain keeps serving for a set time before the listener closes. /health is unchanged. #908 #912 #921
    • ✨ Several instances can share one database: a lease in sys_job_lease lets one of them run the scheduled jobs. Before, every instance ran every job, and each start cleared the others' job entries. #947
    • 🐛 The job scheduler started for the first tenant database only and was never stopped on exit, and a failed port bind still reported the server as started. With several tenant databases, the other tenants' enabled jobs now run. #906
    • 🐛 The queue carrying the login log, operation log and API sync is drained on exit and on a configuration reload instead of dropped. #918 #909
    • 🐛 migrate exits non-zero when it fails, including when the database is unreachable. It used to print the error and exit 0. #926
    • 🐛 Stopping a job that timed out reported success. #924 @jackwalkerlabs
    • 👌 The Docker image no longer installs gcc and g++, 273MB of its 381MB. #925
  • Installable applications
    • ✨ migrate install <code> and migrate uninstall <code> install and remove an application compiled into the binary, recorded in sys_app. migrate status, --dry-run and --app show and limit what runs, per application. #891 #923 #926 #931 #934
    • ✨ example/app-order is a reference application that depends only on go-admin-core, and docs/contract.md states what an application can rely on. common/models, common/dto and common/actions are now aliases of core's contract packages; existing code compiles unchanged. #898 #899 #900 #901 #902
  • Code generator
    • ✨ Generates Vue 3 and TypeScript pages built on PageContainer, ProTable, useTable and useForm, with language packs, column widths and default values. #943
    • ✨ Any single-column primary key, int or string, generates a working backend and page. A table without exactly one key column is refused. #950 #951
    • 🐛 A generated Update that did not find its row inserted a new one. Services generated by earlier versions keep that Update: regenerate them, or apply the change in #950 by hand. #950
    • 🐛 Saving a table's configuration or generating code reported success when part of it failed, and a path it could not write ended the server process. #952 #953
    • 🐛 created_at and updated_at can be listed and queried from the config page, and a table with nothing to enter gets no empty form. #954
    • 🐛 Importing tables failed with go-admin-ui v3.2.0. #936
  • Other fixes
    • 🐛 On PostgreSQL, operation log rows whose result held multi-byte characters were silently dropped. #944 @amiaogo
    • 🐛 config/pg.sql calibrated sequences no column uses for sys_config and sys_job, leaving their real ones unset. #945 @amiaogo
    • 🐛 The password hook hashed an already-hashed password again when a user row was saved with it. It now leaves a hash alone. #889
    • 🐛 SysApi.Update ignored data permission. #889
    • 🐛 The Cache-Control header carried a stray value token. #938
    • 👌 A request body is copied only when the operation log stores it, and at most 32KB of it. A 1MB upload used to allocate 4.3MB. #889
  • 🔧 go-admin-core v2.3.0 → v2.11.0. #894 #909 #949 #953
  • ✅ CI runs the tests with the race detector against MySQL, PostgreSQL, SQL Server and Redis, and fails on unformatted code. #888 #922 #927 #942 #939 #937 #946 #907 #905 @Tuoxie423
  • 📝 Documentation fixes. #887 #893 #910 #916 #930 #941 @Tuoxie423

本次发布需要 Go 1.27.1 并执行一次 migrate,代码生成器改为生成 Vue 3 页面。升级前请先读下面这一节。

⚠️ 升级前

1. 用 Go 1.27.1 或更高版本编译。 在 Go 1.26.5 下,govulncheck 报告本代码会触及 7 个标准库漏洞;在 1.27.1 下为 0。go-admin-core v2.10.0 起声明 go 1.27.1。#948

2. 执行 migrate。 新增 6 个迁移(1786700005000 至 1786700010000),包括应用注册表、定时任务的租约行、代码生成器的列布局字段。迁移完成前,新增的 /api/v1/ready 返回 503,并指出是哪个库落后了。PostgreSQL 上,v2.6.0 会卡在 1786700003000,之后登录报 unable to encode 0 into binary format for timestamptz;本版修好了这个迁移,请再执行一次 migrate。#921 #922

3. 代码生成器只在 dev 和 demo 模式下写文件。 它的三个写接口此前任何已登录账号都能调用。application.mode 为 test、prod 或未设置时,这三个接口不再注册。生成的页面改为 Vue 3,需要 go-admin-ui v3.3.0 或更高版本。#917 #943 #951


  • 🔒 安全
    • 🔒 任何已登录用户都能通过 PUT /api/v1/sys-user 修改他人资料,包括角色。#896
    • 🔒 数据权限有三处会放行:数据库出错时请求不带范围继续执行;无法识别的 data_scope 等同于全部数据;部门 id 为 0 时匹配所有部门。现在无法识别的范围匹配不到任何行,并由迁移把这类取值(包括种子数据给 admin 的空值)改为 1(全部数据)。#897 #904
    • 🔒 demo 模式放行了代码生成器的写接口,因为它们是 GET 请求。#913
  • 部署与关闭
    • ✨ SIGTERM 会执行优雅关闭。此前只处理 SIGINT,所以 docker stop、Kubernetes 和 systemd 会在请求处理途中直接结束进程。#903
    • ✨ /api/v1/ready 报告数据库、缓存和表结构是否可用,并从开始关闭的那一刻起返回失败。extend.shutdown.drain 可以在关闭监听前继续服务一段设定的时间。/health 不变。#908 #912 #921
    • ✨ 多个实例可以共用一个库:sys_job_lease 里的租约让其中一个实例执行定时任务。此前每个实例都执行全部任务,而且每次启动都会清掉其他实例的任务记录。#947
    • 🐛 定时任务调度器只为第一个租户库启动,退出时也从未被停止;端口绑定失败时仍报告服务已启动。配置了多个租户库时,其他租户里启用的任务现在会开始运行。#906
    • 🐛 承载登录日志、操作日志和 API 同步的队列,在退出和配置热重载时会先排空,不再丢弃。#918 #909
    • 🐛 migrate 失败时以非零码退出,包括数据库连不上的情况。此前只打印错误、以 0 退出。#926
    • 🐛 停止任务超时时报告成功。#924 @jackwalkerlabs
    • 👌 Docker 镜像不再安装 gcc 和 g++,它们占 381MB 中的 273MB。#925
  • 可安装应用
    • ✨ migrate install <code> 和 migrate uninstall <code> 安装、卸载编译进二进制的应用,并记录在 sys_app。migrate status、--dry-run 和 --app 按应用显示和限定要执行的内容。#891 #923 #926 #931 #934
    • ✨ example/app-order 是只依赖 go-admin-core 的参照应用,docs/contract.md 说明应用可以依赖什么。common/models、common/dto 和 common/actions 改为 core 契约包的别名,现有代码无需修改即可编译。#898 #899 #900 #901 #902
  • 代码生成器
    • ✨ 生成 Vue 3 + TypeScript 页面,基于 PageContainer、ProTable、useTable 和 useForm,带语言包、列宽和默认值。#943
    • ✨ 任意单列主键(int 或 string)都能生成可用的后端和页面。主键不是恰好一列的表会被拒绝。#950 #951
    • 🐛 生成的 Update 找不到记录时会插入一条新记录。旧版本生成的 service 仍是原来的 Update:请重新生成,或按 #950 手工修改。#950
    • 🐛 保存表配置或生成代码时部分失败仍报告成功;写不了的路径会让服务进程退出。#952 #953
    • 🐛 配置页可以把 created_at 和 updated_at 设为列表列和查询条件;没有可填写字段的表不再生成空表单。#954
    • 🐛 配合 go-admin-ui v3.2.0 导入表时失败。#936
  • 其他修复
    • 🐛 PostgreSQL 上,返回值含多字节字符的操作日志会被静默丢弃。#944 @amiaogo
    • 🐛 config/pg.sql 为 sys_config 和 sys_job 校准的是没有任何列使用的序列,真正的序列没有被设置。#945 @amiaogo
    • 🐛 保存用户时若带上了密码字段,密码钩子会把已经是哈希的密码再哈希一次。现在遇到哈希值会原样保留。#889
    • 🐛 SysApi.Update 没有应用数据权限。#889
    • 🐛 Cache-Control 响应头里多了一个 value。#938
    • 👌 请求体只在操作日志需要存储时才复制,且最多 32KB。此前上传 1MB 会分配 4.3MB 内存。#889
  • 🔧 go-admin-core v2.3.0 → v2.11.0。#894 #909 #949 #953
  • ✅ CI 带竞态检测运行测试,覆盖 MySQL、PostgreSQL、SQL Server 和 Redis,代码未格式化时失败。#888 #922 #927 #942 #939 #937 #946 #907 #905 @Tuoxie423
  • 📝 文档修正。#887 #893 #910 #916 #930 #941 @Tuoxie423