SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

-- 房内猜拳复用游戏管理权限，只新增菜单入口；业务配置和订单状态仍由 game-service 按房内猜拳域独立维护。
SET @now_ms = CAST(UNIX_TIMESTAMP(UTC_TIMESTAMP(3)) * 1000 AS UNSIGNED);

INSERT INTO admin_menus (parent_id, title, code, path, icon, permission_code, sort, visible, created_at_ms, updated_at_ms)
SELECT parent.id, '房内猜拳配置', 'room-rps-config', '/games/room-rps/config', 'settings', 'game:view', 100, TRUE, @now_ms, @now_ms
FROM admin_menus parent
WHERE parent.code = 'games'
ON DUPLICATE KEY UPDATE
  parent_id = VALUES(parent_id),
  title = VALUES(title),
  path = VALUES(path),
  icon = VALUES(icon),
  permission_code = VALUES(permission_code),
  sort = VALUES(sort),
  visible = VALUES(visible),
  updated_at_ms = @now_ms;

INSERT INTO admin_menus (parent_id, title, code, path, icon, permission_code, sort, visible, created_at_ms, updated_at_ms)
SELECT parent.id, '房内猜拳订单', 'room-rps-challenges', '/games/room-rps/challenges', 'history', 'game:view', 110, TRUE, @now_ms, @now_ms
FROM admin_menus parent
WHERE parent.code = 'games'
ON DUPLICATE KEY UPDATE
  parent_id = VALUES(parent_id),
  title = VALUES(title),
  path = VALUES(path),
  icon = VALUES(icon),
  permission_code = VALUES(permission_code),
  sort = VALUES(sort),
  visible = VALUES(visible),
  updated_at_ms = @now_ms;
