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

CREATE TABLE `kku_pet_active_skills` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `pet_id` bigint(20) unsigned NOT NULL COMMENT '宠物ID',
  `skill_id` int(10) unsigned NOT NULL COMMENT '技能ID',
  `skill_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '技能名称',
  `start_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '开始时间',
  `end_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '结束时间',
  `status` enum('active','expired','cancelled') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active' COMMENT '状态：active-生效中，expired-已过期，cancelled-已取消',
  `config` json DEFAULT NULL COMMENT '技能配置信息',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_pet_status` (`pet_id`,`status`) USING BTREE,
  KEY `idx_skill_status` (`skill_name`,`status`) USING BTREE,
  KEY `idx_end_time_status` (`end_time`,`status`) USING BTREE,
  KEY `idx_start_time` (`start_time`) USING BTREE,
  KEY `kku_pet_active_skills_skill_id_foreign` (`skill_id`) USING BTREE,
  CONSTRAINT `kku_pet_active_skills_pet_id_foreign` FOREIGN KEY (`pet_id`) REFERENCES `kku_pet_users` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
  CONSTRAINT `kku_pet_active_skills_skill_id_foreign` FOREIGN KEY (`skill_id`) REFERENCES `kku_pet_skills` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='宠物激活技能表 - 记录宠物当前激活的技能状态';
