-- tyl 
-- 孩子日志
drop table if exists log_child_grow_up;
drop table if exists log_child_upgrade;
drop table if exists log_child_fashion;
drop table if exists log_child_vehicle;
drop table if exists log_child_skill;
drop table if exists log_child_toy;
drop table if exists log_child_toy_suit;
drop table if exists log_child_toy_box;
drop table if exists log_child_vote_reward;


CREATE TABLE `log_child_item` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '操作类型 1-激活 2-升级',
  `item_type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '物品类型 1-时装 2-载具',
  `item_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '物品id',
  `cost` varchar(255) NOT NULL DEFAULT '[]' COMMENT '消耗',
  `grade_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前等级',
  `grade_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后等级',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`,`item_type`) USING BTREE,
  KEY `time` (`time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='孩子时装/载具日志表';

CREATE TABLE `log_child_link_heart` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '操作类型 1-任务 2-消耗材料',
  `task_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '任务Id',
  `cost` varchar(255) NOT NULL DEFAULT '[]' COMMENT '消耗材料',
  `link_heart_get` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '获得同心值',
  `link_heart_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '前同心值',
  `link_heart_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '后同心值',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`) USING BTREE,
  KEY `type` (`role_id`,`type`) USING BTREE,
  KEY `time` (`time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='孩子同心值日志表';

CREATE TABLE `log_child_rank` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `child_name` varchar(255) NOT NULL DEFAULT '' COMMENT '孩子名称',
  `rank` smallint(5) unsigned NOT NULL DEFAULT '0' COMMENT '排行',
  `vote` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '投票数',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='孩子排行榜日志表';

CREATE TABLE `log_child_skill` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `skill_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '技能Id',
  `lv_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前等级',
  `lv_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后等级',
  `cost` varchar(500) NOT NULL DEFAULT '[]' COMMENT '消耗',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`) USING BTREE,
  KEY `time` (`time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='孩子技能日志表';

CREATE TABLE `log_child_toy` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `suit_type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '玩具套装类型',
  `toy_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '玩具Id',
  `cost` varchar(500) NOT NULL DEFAULT '[]' COMMENT '消耗材料',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

CREATE TABLE `log_child_toy_box` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `type` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '操作类型 1-分解玩具 2-使用玩具精华',
  `lv_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前等级',
  `lv_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后等级',
  `exp_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前经验值',
  `exp_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后经验值',
  `toy_cost` varchar(500) CHARACTER SET utf8 NOT NULL DEFAULT '[]' COMMENT '消耗材料',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`,`type`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin ROW_FORMAT=COMPACT;

CREATE TABLE `log_child_upgrade` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
  `role_id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '角色Id',
  `grade_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前阶数',
  `star_bef` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作前星数',
  `grade_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后阶数',
  `star_aft` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作后星数',
  `cost` varchar(255) NOT NULL DEFAULT '[]' COMMENT '消耗材料',
  `time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '时间',
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`) USING BTREE,
  KEY `time` (`time`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;