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

CREATE TABLE `kku_item_recipe_materials` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID，主键',
  `recipe_id` int NOT NULL COMMENT '配方ID，外键关联kku_item_recipes表',
  `item_id` int NOT NULL COMMENT '材料物品ID，外键关联kku_item_items表',
  `quantity` int NOT NULL COMMENT '所需数量',
  `is_consumed` tinyint DEFAULT '1' COMMENT '是否消耗（0:不消耗, 1:消耗）',
  `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_recipe_id` (`recipe_id`) USING BTREE,
  KEY `idx_item_id` (`item_id`) USING BTREE,
  CONSTRAINT `fk_material_item` FOREIGN KEY (`item_id`) REFERENCES `kku_item_items` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
  CONSTRAINT `fk_material_recipe` FOREIGN KEY (`recipe_id`) REFERENCES `kku_item_recipes` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='配方材料需求表';
