This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new ef5b203c3 fix(deploy): use gmt_create in the nameserver unique-key
migration (#4721)
ef5b203c3 is described below
commit ef5b203c36aec04b7945a1ce5cddf6f8448463b7
Author: Apulupie <[email protected]>
AuthorDate: Mon Sep 21 21:10:52 2026 +0800
fix(deploy): use gmt_create in the nameserver unique-key migration (#4721)
`deploy/mysql/upgrade-nameserver-name-uk.sql` deduplicated `rmq_nameserver`
rows by comparing `k.created_at` with `i.created_at`, but that table's column
is `gmt_create`: `schema.sql` defines the standard `id` / `gmt_create` /
`gmt_modified` triple and `RmqNameserver` maps `gmtCreate`. The `DELETE ...
JOIN` therefore aborts with an unknown-column error and the script never
reaches the `ALTER TABLE ... ADD UNIQUE KEY` it exists for. The window is real
rather than theoretical — `uk_name [...]
All four `created_at` references, the two comparison predicates and the two
comments describing them, now say `gmt_create`. The SQL structure, the
idempotence guard and `SET NAMES` are untouched.
The sibling `upgrade-instance-name-uk.sql` keeps its `created_at` wording
on purpose: the unique key it backfills predates the rename, so every volume
that needs that script is from before `gmt_create` existed.
Fixes #4722
---
deploy/mysql/upgrade-nameserver-name-uk.sql | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/deploy/mysql/upgrade-nameserver-name-uk.sql
b/deploy/mysql/upgrade-nameserver-name-uk.sql
index 5427cdb7f..d723bdf42 100644
--- a/deploy/mysql/upgrade-nameserver-name-uk.sql
+++ b/deploy/mysql/upgrade-nameserver-name-uk.sql
@@ -5,7 +5,7 @@
-- 全新数据卷由 server/src/main/resources/db/schema.sql 直接带上
uk_nameserver_name。
-- 幂等:可重复执行。
--
--- ⚠️ 会删除同名重复记录(保留 created_at 最早的一条)。执行前可先用下面的查询核对重复:
+-- ⚠️ 会删除同名重复记录(保留 gmt_create 最早的一条)。执行前可先用下面的查询核对重复:
-- SELECT name, COUNT(*) FROM rmq_nameserver GROUP BY name HAVING COUNT(*) >
1;
--
-- 用法(远程容器内执行):
@@ -13,12 +13,12 @@
SET NAMES utf8mb4;
--- 1. 清理同名重复(保留 created_at 最早,id 最小作为并列时的决胜)
+-- 1. 清理同名重复(保留 gmt_create 最早,id 最小作为并列时的决胜)
DELETE i FROM rmq_nameserver i
JOIN rmq_nameserver k
ON k.name = i.name
- AND (k.created_at < i.created_at
- OR (k.created_at = i.created_at AND k.id < i.id));
+ AND (k.gmt_create < i.gmt_create
+ OR (k.gmt_create = i.gmt_create AND k.id < i.id));
-- 2. 追加唯一键(仅当不存在时)
SET @uk_exists := (