-- 删除装备物品旧代码
drop table if exists goods_extra;
drop table if exists log_goods_compose;
drop table if exists equip_devour;
drop table if exists log_equip_devour;

-- tyl
-- 成就
TRUNCATE TABLE achievement;
ALTER TABLE achievement 
CHANGE COLUMN `id` `category` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '章节' AFTER `role_id`,
ADD COLUMN `sub_category` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '小类' AFTER `category`;
ALTER TABLE achievement
DROP PRIMARY KEY, ADD PRIMARY KEY(`role_id`,`category`,`sub_category`);


TRUNCATE TABLE achievement_star_reward;
RENAME TABLE achievement_star_reward TO achievement_category_reward;
ALTER TABLE achievement_category_reward 
CHANGE COLUMN `star` `category` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '章节' AFTER `role_id`;

ALTER TABLE log_achv
DROP COLUMN achv_id,
ADD COLUMN category SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '章节' AFTER `lv`,
ADD COLUMN sub_category SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 COMMENT '小类' AFTER `category`;

CREATE TABLE IF NOT EXISTS `achievement_lv` (
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `lv` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '成就等级',
  `exp` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '成就经验',
  `lv_reward_list` varchar(500) NOT NULL DEFAULT '[]' COMMENT '成就奖励领取状态[{lv, status}]',
  PRIMARY KEY (`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='成就等级数据表';
