-- =====================================================
-- 将只有一个子菜单的父菜单扁平化为一级菜单
-- （去掉下拉箭头，直接显示为可点击的菜单项）
-- =====================================================
UPDATE t_menu
SET show_parent = 0
WHERE id IN (
    SELECT parent_id FROM (
        SELECT parent_id, COUNT(*) AS cnt
        FROM t_menu
        WHERE deleted = 0 AND parent_id > 0
        GROUP BY parent_id
    ) t
    WHERE t.cnt = 1
)
AND deleted = 0;
