thirdparty_quotas.sql 1.9 KB

1234567891011121314151617181920212223242526272829
  1. -- ******************************************************************
  2. -- 表 kku_thirdparty_quotas 的创建SQL
  3. -- 对应的Model: App\Module\ThirdParty\Models\ThirdPartyQuota
  4. -- 警告: 此文件由系统自动生成,禁止修改!
  5. -- ******************************************************************
  6. CREATE TABLE `kku_thirdparty_quotas` (
  7. `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  8. `service_id` bigint(20) unsigned NOT NULL COMMENT '服务ID',
  9. `type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '配额类型',
  10. `limit_value` bigint(20) NOT NULL COMMENT '限制值',
  11. `used_value` bigint(20) DEFAULT '0' COMMENT '已使用值',
  12. `reset_at` timestamp NULL DEFAULT NULL COMMENT '重置时间',
  13. `window_start` timestamp NULL DEFAULT NULL COMMENT '时间窗口开始',
  14. `window_end` timestamp NULL DEFAULT NULL COMMENT '时间窗口结束',
  15. `is_active` tinyint(1) DEFAULT '1' COMMENT '是否激活',
  16. `alert_threshold` decimal(5,2) DEFAULT '80.00' COMMENT '告警阈值(百分比)',
  17. `is_exceeded` tinyint(1) DEFAULT '0' COMMENT '是否已超限',
  18. `exceeded_at` timestamp NULL DEFAULT NULL COMMENT '超限时间',
  19. `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  20. `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  21. PRIMARY KEY (`id`) USING BTREE,
  22. UNIQUE KEY `uk_service_type` (`service_id`,`type`) USING BTREE,
  23. KEY `idx_type` (`type`) USING BTREE,
  24. KEY `idx_is_active` (`is_active`) USING BTREE,
  25. KEY `idx_is_exceeded` (`is_exceeded`) USING BTREE,
  26. KEY `idx_reset_at` (`reset_at`) USING BTREE,
  27. CONSTRAINT `fk_quotas_service` FOREIGN KEY (`service_id`) REFERENCES `kku_thirdparty_services` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
  28. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='配额管理表';