SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

-- 左侧父级菜单顺序直接影响后台入口效率：团队管理靠近用户管理，后台设置固定沉到底部。
SET @now_ms = CAST(UNIX_TIMESTAMP(UTC_TIMESTAMP(3)) * 1000 AS UNSIGNED);

UPDATE admin_menus
SET sort = CASE code
    WHEN 'overview' THEN 10
    WHEN 'app-users' THEN 20
    WHEN 'host-org' THEN 30
    WHEN 'rooms' THEN 40
    WHEN 'app-config' THEN 50
    WHEN 'resources' THEN 60
    WHEN 'operations' THEN 70
    WHEN 'payment' THEN 80
    WHEN 'activities' THEN 90
    WHEN 'games' THEN 100
    WHEN 'geo' THEN 110
    WHEN 'system' THEN 120
    WHEN 'logs' THEN 130
    ELSE sort
  END,
  updated_at_ms = @now_ms
WHERE parent_id IS NULL
  AND code IN (
    'overview',
    'app-users',
    'host-org',
    'rooms',
    'app-config',
    'resources',
    'operations',
    'payment',
    'activities',
    'games',
    'geo',
    'system',
    'logs'
  );
