feat(llm-proxy): 新增 pipeline_llm_tokens 表(短期 token + 用量)

This commit is contained in:
yumoqing 2026-08-25 14:11:42 +08:00
parent 89f670af88
commit 16fd5a3530

View File

@ -134,6 +134,31 @@ CREATE TABLE IF NOT EXISTS pipeline_session_settings (
KEY `idx_session` (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
""",
"""
CREATE TABLE IF NOT EXISTS pipeline_llm_tokens (
`id` varchar(32) NOT NULL,
`token` varchar(80) NOT NULL,
`org_id` varchar(32) NOT NULL DEFAULT '0',
`project_id` varchar(32) NOT NULL DEFAULT '',
`task_id` varchar(32) NOT NULL DEFAULT '',
`model_name` varchar(100) NOT NULL DEFAULT '',
`purpose` varchar(100) NOT NULL DEFAULT '',
`status` varchar(20) NOT NULL DEFAULT 'active',
`expires_at` datetime NOT NULL,
`max_calls` int(11) NOT NULL DEFAULT 500,
`call_count` int(11) NOT NULL DEFAULT 0,
`prompt_tokens` bigint(20) NOT NULL DEFAULT 0,
`completion_tokens` bigint(20) NOT NULL DEFAULT 0,
`created_by` varchar(64) NOT NULL DEFAULT '',
`created_at` datetime NOT NULL DEFAULT current_timestamp(),
`last_used_at` datetime NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `uk_token` (`token`),
KEY `idx_org` (`org_id`),
KEY `idx_project` (`project_id`),
KEY `idx_status_exp` (`status`,`expires_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
""",
]
# v2 引擎列迁移(原 init.py::_init_v2_tables 启动时 ALTER 迁移现迁到部署期information_schema 幂等)