/*
 修复魅力等级表结构
 使其与后端代码匹配
 
 Date: 2025-12-30
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- 删除旧表并重建
DROP TABLE IF EXISTS `eb_charm_level`;
CREATE TABLE `eb_charm_level` (
  `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `level` int UNSIGNED NOT NULL COMMENT '等级',
  `upgrade_condition` int UNSIGNED NOT NULL DEFAULT 0 COMMENT '升级条件(所需魅力值)',
  `charm_title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '魅力称号',
  `icon` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '等级图标',
  `privileges` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '等级特权(JSON)',
  `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态 0=禁用 1=启用',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_level` (`level`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '魅力等级表' ROW_FORMAT = DYNAMIC;

-- 插入默认魅力等级数据
INSERT INTO `eb_charm_level` (`level`, `upgrade_condition`, `charm_title`) VALUES
(1, 0, '魅力新星'),
(2, 100, '魅力达人'),
(3, 500, '魅力之星'),
(4, 1000, '魅力精英'),
(5, 3000, '魅力大师'),
(6, 8000, '魅力王者'),
(7, 20000, '魅力传说'),
(8, 50000, '魅力至尊');

SET FOREIGN_KEY_CHECKS = 1;
