cleanup_logs.sql 1.7 KB

123456789101112131415161718192021222324252627
  1. -- ******************************************************************
  2. -- 表 kku_cleanup_logs 的创建SQL
  3. -- 对应的Model: App\Module\Cleanup\Models\CleanupLog
  4. -- 警告: 此文件由系统自动生成,禁止修改!
  5. -- ******************************************************************
  6. CREATE TABLE `kku_cleanup_logs` (
  7. `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  8. `task_id` bigint unsigned NOT NULL COMMENT '任务ID',
  9. `table_name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '表名',
  10. `model_class` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Model类名',
  11. `cleanup_type` tinyint unsigned NOT NULL COMMENT '清理类型:1清空表,2删除所有,3按时间删除,4按用户删除,5按条件删除',
  12. `before_count` bigint unsigned NOT NULL DEFAULT '0' COMMENT '清理前记录数',
  13. `after_count` bigint unsigned NOT NULL DEFAULT '0' COMMENT '清理后记录数',
  14. `deleted_records` bigint unsigned NOT NULL DEFAULT '0' COMMENT '删除记录数',
  15. `execution_time` decimal(8,3) NOT NULL DEFAULT '0.000' COMMENT '执行时间(秒)',
  16. `conditions` json DEFAULT NULL COMMENT '使用的清理条件',
  17. `error_message` text COLLATE utf8mb4_unicode_ci COMMENT '错误信息',
  18. `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  19. PRIMARY KEY (`id`),
  20. KEY `idx_task_id` (`task_id`),
  21. KEY `idx_table_name` (`table_name`),
  22. KEY `idx_cleanup_type` (`cleanup_type`),
  23. KEY `idx_created_at` (`created_at`),
  24. KEY `idx_model_class` (`model_class`),
  25. CONSTRAINT `kku_cleanup_logs_ibfk_1` FOREIGN KEY (`task_id`) REFERENCES `kku_cleanup_tasks` (`id`) ON DELETE CASCADE
  26. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='清理日志表';