20260905_create_tk_aiopen_risk_daily.sql 1.6 KB

12345678910111213141516171819202122
  1. -- 请在 CenterDB(后台报表库)执行。
  2. CREATE TABLE IF NOT EXISTS `tk_aiopen_risk_daily` (
  3. `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  4. `report_date` DATE NOT NULL COMMENT '统计日期(Asia/Shanghai)',
  5. `account_id` INT NOT NULL COMMENT 'tk_pool.id',
  6. `account_name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT '触发时账号名称',
  7. `endpoint_id` INT NOT NULL DEFAULT 8 COMMENT 'tk_endpoint_config.ep_id',
  8. `endpoint_name` VARCHAR(64) NOT NULL DEFAULT 'aiopen' COMMENT '端点名称',
  9. `reason_code` VARCHAR(64) NOT NULL COMMENT '稳定风控代码',
  10. `reason` VARCHAR(512) NOT NULL DEFAULT '' COMMENT '上游bizErrorDesc',
  11. `biz_error_code` INT NOT NULL DEFAULT 0 COMMENT '上游bizErrorCode',
  12. `result_code` INT NOT NULL DEFAULT 0 COMMENT '上游resultCode',
  13. `first_trigger_time` DATETIME(3) NOT NULL COMMENT '当日首次触发时间',
  14. `request_count_at_trigger` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '包含触发请求的当日端点调用数',
  15. `success_count_at_trigger` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT '触发时当日成功数',
  16. `release_time` DATETIME(3) NOT NULL COMMENT '预计自动释放时间',
  17. `create_time` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
  18. PRIMARY KEY (`id`),
  19. UNIQUE KEY `uk_date_account_reason` (`report_date`, `account_id`, `reason_code`),
  20. KEY `idx_report_date_trigger_time` (`report_date`, `first_trigger_time`),
  21. KEY `idx_account_trigger_time` (`account_id`, `first_trigger_time`)
  22. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='AI Open账号每日首次风控事件';