item_output_limits.sql 1.3 KB

12345678910111213141516171819
  1. -- 表 kku_item_output_limits 的创建SQL
  2. DROP TABLE IF EXISTS `kku_item_output_limits`;
  3. CREATE TABLE `kku_item_output_limits` (
  4. `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
  5. `item_id` int NOT NULL COMMENT '物品ID,外键关联kku_item_items表',
  6. `limit_type` tinyint NOT NULL COMMENT '限制类型(1:全局总量, 2:单个用户, 3:单日全局, 4:单日用户)',
  7. `max_quantity` int NOT NULL COMMENT '最大产出数量',
  8. `current_quantity` int DEFAULT '0' COMMENT '当前已产出数量(全局限制时使用)',
  9. `reset_type` tinyint DEFAULT '0' COMMENT '重置类型(0:不重置, 1:每日, 2:每周, 3:每月)',
  10. `last_reset_time` timestamp NULL DEFAULT NULL COMMENT '上次重置时间',
  11. `related_items` json DEFAULT NULL COMMENT '关联物品ID列表,这些物品共享同一个限制额度',
  12. `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  13. `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  14. PRIMARY KEY (`id`),
  15. KEY `idx_item_id` (`item_id`),
  16. KEY `idx_limit_reset` (`limit_type`,`reset_type`),
  17. CONSTRAINT `fk_limit_item` FOREIGN KEY (`item_id`) REFERENCES `kku_item_items` (`id`) ON DELETE CASCADE
  18. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='物品产出限制表';