SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

SET @now_ms = CAST(UNIX_TIMESTAMP(UTC_TIMESTAMP(3)) * 1000 AS UNSIGNED);

-- 查询与写入都命中 uk_admin_app_config_app_group_key(app_code, group, key)，只处理两个常量行，
-- 不扫描礼物、账务或配置事实表。重复执行时保留管理员已经保存的值，避免回滚线上档位。
INSERT INTO admin_app_configs (app_code, `group`, `key`, value, description, is_deleted, created_at_ms, updated_at_ms)
VALUES
  ('lalu', 'room-gift', 'quantity-presets', '[1,7,77,777,7777]', '语音房送礼数量档位，严格递增且每档为 1-9999', FALSE, @now_ms, @now_ms),
  ('fami', 'room-gift', 'quantity-presets', '[1,7,77,777,7777]', '语音房送礼数量档位，严格递增且每档为 1-9999', FALSE, @now_ms, @now_ms)
ON DUPLICATE KEY UPDATE id = id;

INSERT INTO admin_menus (parent_id, title, code, path, icon, permission_code, sort, visible, created_at_ms, updated_at_ms)
SELECT parent.id, '送礼配置', 'app-config-gift', '/app-config/gift', 'gift', 'app-config:view', 74, TRUE, @now_ms, @now_ms
FROM admin_menus parent
WHERE parent.code = 'app-config'
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 = VALUES(updated_at_ms);
