SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

-- 056 初版曾把转盘抽奖放在运营管理；这里单独迁移到活动管理，保证已执行过 056 的库也能修正菜单位置。
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) VALUES
  (NULL, '活动管理', 'activities', '', 'campaign', '', 80, TRUE, @now_ms, @now_ms)
ON DUPLICATE KEY UPDATE
  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;

UPDATE admin_menus wheel
JOIN admin_menus activities ON activities.code = 'activities'
SET wheel.parent_id = activities.id,
    wheel.path = '/activities/wheel',
    wheel.sort = 80,
    wheel.icon = 'casino',
    wheel.permission_code = 'wheel:view',
    wheel.visible = TRUE,
    wheel.updated_at_ms = @now_ms
WHERE wheel.code = 'wheel';
