-- 从所有角色中移除以下运维菜单及其按钮权限
-- /safeguard/dict
-- /safeguard/attachment
-- /safeguard/database
-- /safeguard/server
-- /safeguard/cache
-- /safeguard/email-log
--
-- 推荐执行：php db/run_remove_safeguard_ops_role_menus.php
-- 该脚本会按 route 动态匹配菜单及其子权限，并清理菜单缓存

-- 主菜单
DELETE rm FROM `sa_system_role_menu` rm
INNER JOIN `sa_system_menu` m ON rm.menu_id = m.id
WHERE m.component IN (
    '/safeguard/dict',
    '/safeguard/attachment',
    '/safeguard/database',
    '/safeguard/server',
    '/safeguard/cache',
    '/safeguard/email-log'
);

-- 子按钮权限
DELETE rm FROM `sa_system_role_menu` rm
INNER JOIN `sa_system_menu` child ON rm.menu_id = child.id
INNER JOIN `sa_system_menu` parent ON child.parent_id = parent.id
WHERE parent.component IN (
    '/safeguard/dict',
    '/safeguard/attachment',
    '/safeguard/database',
    '/safeguard/server',
    '/safeguard/cache',
    '/safeguard/email-log'
);
