Files
taiji-AI-PAD/services/mcp-server/migrations/001_add_resource_control_fields.sql
T
2025-12-30 06:22:47 +00:00

33 lines
988 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 资源管控字段迁移脚本
-- 为users表添加资源限制字段
-- 添加rpm_limit字段(每分钟请求数限制)
ALTER TABLE users
ADD COLUMN IF NOT EXISTS rpm_limit INTEGER DEFAULT 60;
-- 添加tpm_limit字段(每分钟Token数限制)
ALTER TABLE users
ADD COLUMN IF NOT EXISTS tpm_limit INTEGER DEFAULT 10000;
-- 添加daily_cost_limit字段(每日成本限制)
ALTER TABLE users
ADD COLUMN IF NOT EXISTS daily_cost_limit NUMERIC(12, 2) DEFAULT 100.00;
-- 为现有用户设置默认值
UPDATE users
SET rpm_limit = 60
WHERE rpm_limit IS NULL;
UPDATE users
SET tpm_limit = 10000
WHERE tpm_limit IS NULL;
UPDATE users
SET daily_cost_limit = 100.00
WHERE daily_cost_limit IS NULL;
-- 添加注释
COMMENT ON COLUMN users.rpm_limit IS '每分钟请求数限制(Requests Per Minute)';
COMMENT ON COLUMN users.tpm_limit IS '每分钟Token数限制(Tokens Per Minute)';
COMMENT ON COLUMN users.daily_cost_limit IS '每日成本限制(元)';