-- ******************************************************************
-- 表 kku_pet_battle_logs 的创建SQL
-- 对应的Model: App\Module\Pet\Models\PetBattleLog
-- 警告: 此文件由系统自动生成，禁止修改！
-- ******************************************************************

CREATE TABLE `kku_pet_battle_logs` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `pet_id` bigint(20) unsigned NOT NULL,
  `battle_type` tinyint(3) unsigned NOT NULL COMMENT '战斗类型：1偷菜，2守护，3争霸赛',
  `opponent_id` bigint(20) unsigned DEFAULT NULL COMMENT '对手ID（可为空）',
  `result` tinyint(3) unsigned NOT NULL COMMENT '战斗结果：0失败，1胜利',
  `reward` json DEFAULT NULL COMMENT '战斗奖励',
  `battle_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_pet` (`pet_id`) USING BTREE,
  KEY `idx_battle_time` (`battle_time`) USING BTREE,
  CONSTRAINT `kku_pet_battle_logs_ibfk_1` FOREIGN KEY (`pet_id`) REFERENCES `kku_pet_users` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='战斗记录';
