Files
ai-gateway-go/migrations/000011_api_key_limits.sql
superidou 5759c1862e AI Gateway Go 0.10.0 源码快照 + 旗舰版需求规划报告
M0-M7 已完成:核心网关(身份/RBAC/TOTP/OIDC/SAML/Provider/配额/路由/内容策略/审计/定价)+ 资源市场(MCP/Skills/数字员工)。
含 22 个 PostgreSQL 迁移、管理端/门户端前端源码、OpenAPI 契约、部署 compose。

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-12 11:45:54 +08:00

19 lines
912 B
SQL

ALTER TABLE gateway.api_keys
ADD COLUMN IF NOT EXISTS requests_per_minute integer NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS monthly_request_quota bigint NOT NULL DEFAULT 0;
ALTER TABLE gateway.api_keys
DROP CONSTRAINT IF EXISTS api_keys_requests_per_minute_check,
DROP CONSTRAINT IF EXISTS api_keys_monthly_request_quota_check;
ALTER TABLE gateway.api_keys
ADD CONSTRAINT api_keys_requests_per_minute_check
CHECK (requests_per_minute BETWEEN 0 AND 1000000),
ADD CONSTRAINT api_keys_monthly_request_quota_check
CHECK (monthly_request_quota BETWEEN 0 AND 1000000000000);
COMMENT ON COLUMN gateway.api_keys.requests_per_minute IS
'Atomic Redis-enforced request limit per UTC minute. Zero means unlimited.';
COMMENT ON COLUMN gateway.api_keys.monthly_request_quota IS
'Atomic Redis-enforced accepted request quota per UTC calendar month. Zero means unlimited.';