-- Migration: add system management root menu and regroup selected modules
-- Created at: 2026-03-12

BEGIN;

-- ensure system_management root menu exists
INSERT INTO sys_menus
(menu_code, menu_name, menu_icon, menu_url, menu_type, parent_id, menu_level, tree_path, sort_order, is_active, is_visible, description)
SELECT
  'system_management',
  '系统管理',
  'Setting',
  '/admin/management/user-management',
  'link',
  NULL,
  1,
  NULL,
  4,
  1,
  1,
  '系统基础配置管理（用户、权限、字段、参数）'
FROM dual
WHERE NOT EXISTS (SELECT 1 FROM sys_menus WHERE menu_code = 'system_management');

COMMIT;
