-- 修改菜单名称的SQL脚本
-- 删除第一个"test"菜单项，将第二个"test"改为"系统管理"

-- 方案1：基于sort字段删除和修改
-- 删除sort值最小的"test"菜单项
DELETE FROM sys_menu 
WHERE name = 'test' 
  AND parent_id = 0 
  AND is_delete = 0 
  AND sort = (
    SELECT min_sort FROM (
      SELECT MIN(sort) as min_sort 
      FROM sys_menu 
      WHERE name = 'test' AND parent_id = 0 AND is_delete = 0
    ) t
  );

-- 将剩余的"test"菜单项改为"系统管理"
UPDATE sys_menu 
SET name = '系统管理', 
    update_time = NOW() 
WHERE name = 'test' 
  AND parent_id = 0 
  AND is_delete = 0;

-- 验证修改结果
SELECT id, parent_id, name, type, sort, icon 
FROM sys_menu 
WHERE is_delete = 0 
ORDER BY sort;
