api_nonces@api_nonces_his.sql 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. api_nonces / api_nonces_his 表结构(与 ORM 模型一致)
  3. - api_nonces: 防重放,主键 id,nonce 唯一
  4. - api_nonces_his: 历史记录,主键 (id, his_created_at),id 为原表主键
  5. Target Server Type : MySQL
  6. Source Schema : buff
  7. Date: 15/02/2026
  8. */
  9. SET NAMES utf8mb4;
  10. SET FOREIGN_KEY_CHECKS = 0;
  11. -- ----------------------------
  12. -- Table structure for api_nonces
  13. -- ----------------------------
  14. DROP TABLE IF EXISTS `api_nonces`;
  15. CREATE TABLE `api_nonces` (
  16. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  17. `nonce` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '随机字符串',
  18. `endpoint` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口路径',
  19. `session_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '会话ID',
  20. `user_id` int(11) DEFAULT NULL COMMENT '用户ID',
  21. `expires_at` datetime NOT NULL COMMENT '过期时间',
  22. `created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  23. PRIMARY KEY (`id`),
  24. UNIQUE KEY `uk_api_nonces_nonce` (`nonce`),
  25. KEY `idx_api_nonces_expires_at` (`expires_at`)
  26. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='API Nonce防重放表';
  27. -- ----------------------------
  28. -- Records of api_nonces (无初始数据)
  29. -- ----------------------------
  30. -- BEGIN;
  31. -- COMMIT;
  32. -- ----------------------------
  33. -- Table structure for api_nonces_his
  34. -- ----------------------------
  35. DROP TABLE IF EXISTS `api_nonces_his`;
  36. CREATE TABLE `api_nonces_his` (
  37. `id` int(11) NOT NULL COMMENT '原表主键ID',
  38. `nonce` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '随机字符串',
  39. `endpoint` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '接口路径',
  40. `session_id` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '会话ID',
  41. `created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  42. `expires_at` datetime NOT NULL COMMENT '过期时间',
  43. `his_created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '历史记录创建时间',
  44. `his_operation` varchar(10) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '操作类型: INSERT/UPDATE/DELETE',
  45. PRIMARY KEY (`id`, `his_created_at`),
  46. KEY `idx_his_created_at` (`his_created_at`),
  47. KEY `idx_nonce` (`nonce`)
  48. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='API Nonce表历史记录';
  49. -- ----------------------------
  50. -- Records of api_nonces_his (无初始数据)
  51. -- ----------------------------
  52. -- BEGIN;
  53. -- COMMIT;
  54. SET FOREIGN_KEY_CHECKS = 1;