diff --git a/drizzle/0020_glossy_grandmaster.sql b/drizzle/0020_glossy_grandmaster.sql new file mode 100644 index 000000000..abe626b84 --- /dev/null +++ b/drizzle/0020_glossy_grandmaster.sql @@ -0,0 +1,48 @@ +-- 幂等迁移: 合并 0020-0025 的所有变更 +-- 此迁移可以在任何状态下安全执行(新安装、从 0019 升级、从冲突版本升级) + +-- Step 0: 清理冲突的旧迁移记录(一次性,仅影响从冲突版本升级的用户) +DELETE FROM drizzle.__drizzle_migrations WHERE hash IN ( + '0020_next_juggernaut', + '0021_daily_cost_limits', + '0022_simple_stardust', + '0023_cheerful_shocker', + '0023_safe_christian_walker', + '0024_update_provider_timeout_defaults', + '0025_hard_violations' +); +--> statement-breakpoint + +-- Step 1: 创建枚举类型(幂等) +DO $$ BEGIN + CREATE TYPE "public"."daily_reset_mode" AS ENUM('fixed', 'rolling'); +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint + +-- Step 2: 更新 providers 表默认值(幂等,无条件安全) +ALTER TABLE "providers" ALTER COLUMN "first_byte_timeout_streaming_ms" SET DEFAULT 0;--> statement-breakpoint +ALTER TABLE "providers" ALTER COLUMN "streaming_idle_timeout_ms" SET DEFAULT 0;--> statement-breakpoint +ALTER TABLE "providers" ALTER COLUMN "request_timeout_non_streaming_ms" SET DEFAULT 0;--> statement-breakpoint + +-- Step 3: 添加 keys 表字段(幂等) +ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "daily_reset_mode" "daily_reset_mode" DEFAULT 'fixed' NOT NULL;--> statement-breakpoint +ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "limit_daily_usd" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "daily_reset_time" varchar(5) DEFAULT '00:00' NOT NULL;--> statement-breakpoint + +-- Step 4: 添加 providers 表字段(幂等) +ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "mcp_passthrough_type" varchar(20) DEFAULT 'none' NOT NULL;--> statement-breakpoint +ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "mcp_passthrough_url" varchar(512);--> statement-breakpoint +ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "daily_reset_mode" "daily_reset_mode" DEFAULT 'fixed' NOT NULL;--> statement-breakpoint +ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "limit_daily_usd" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "daily_reset_time" varchar(5) DEFAULT '00:00' NOT NULL;--> statement-breakpoint + +-- Step 5: 添加 system_settings 表字段(幂等) +ALTER TABLE "system_settings" ADD COLUMN IF NOT EXISTS "billing_model_source" varchar(20) DEFAULT 'original' NOT NULL;--> statement-breakpoint + +-- Step 6: 添加 users 表字段(幂等) +ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "limit_5h_usd" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "limit_weekly_usd" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "limit_monthly_usd" numeric(10, 2);--> statement-breakpoint +ALTER TABLE "users" ADD COLUMN IF NOT EXISTS "limit_concurrent_sessions" integer; diff --git a/drizzle/0020_next_juggernaut.sql b/drizzle/0020_next_juggernaut.sql deleted file mode 100644 index 6e5516eb9..000000000 --- a/drizzle/0020_next_juggernaut.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE "users" ADD COLUMN "limit_5h_usd" numeric(10, 2);--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "limit_weekly_usd" numeric(10, 2);--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "limit_monthly_usd" numeric(10, 2);--> statement-breakpoint -ALTER TABLE "users" ADD COLUMN "limit_concurrent_sessions" integer; \ No newline at end of file diff --git a/drizzle/0021_daily_cost_limits.sql b/drizzle/0021_daily_cost_limits.sql deleted file mode 100644 index 94acd556c..000000000 --- a/drizzle/0021_daily_cost_limits.sql +++ /dev/null @@ -1,45 +0,0 @@ --- 每日成本限额功能 - 统一迁移文件 (修正 Enum 版) --- 包含:创建枚举类型、添加字段、设置约束、添加重置模式 - --- Step 0: 安全创建枚举类型 (如果不存在则创建) -DO $$ BEGIN - CREATE TYPE "daily_reset_mode" AS ENUM('fixed', 'rolling'); -EXCEPTION - WHEN duplicate_object THEN null; -END $$; ---> statement-breakpoint - --- Step 1: 添加基础字段 -ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "limit_daily_usd" numeric(10, 2);--> statement-breakpoint -ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "daily_reset_time" varchar(5) DEFAULT '00:00';--> statement-breakpoint -ALTER TABLE "keys" ADD COLUMN IF NOT EXISTS "daily_reset_mode" "daily_reset_mode" DEFAULT 'fixed' NOT NULL;--> statement-breakpoint - -ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "limit_daily_usd" numeric(10, 2);--> statement-breakpoint -ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "daily_reset_time" varchar(5) DEFAULT '00:00';--> statement-breakpoint -ALTER TABLE "providers" ADD COLUMN IF NOT EXISTS "daily_reset_mode" "daily_reset_mode" DEFAULT 'fixed' NOT NULL;--> statement-breakpoint - --- Step 2: 数据清理和约束设置 -UPDATE "keys" -SET "daily_reset_time" = '00:00' -WHERE "daily_reset_time" IS NULL OR trim("daily_reset_time") = '';--> statement-breakpoint -ALTER TABLE "keys" ALTER COLUMN "daily_reset_time" SET DEFAULT '00:00';--> statement-breakpoint -ALTER TABLE "keys" ALTER COLUMN "daily_reset_time" SET NOT NULL;--> statement-breakpoint - -UPDATE "providers" -SET "daily_reset_time" = '00:00' -WHERE "daily_reset_time" IS NULL OR trim("daily_reset_time") = '';--> statement-breakpoint -ALTER TABLE "providers" ALTER COLUMN "daily_reset_time" SET DEFAULT '00:00';--> statement-breakpoint -ALTER TABLE "providers" ALTER COLUMN "daily_reset_time" SET NOT NULL; - ---> statement-breakpoint --- Step 3: 修正现有列类型 (防止之前已创建为 varchar) --- 如果字段已经是 daily_reset_mode 类型,这步操作是安全的(无操作) --- 如果字段是 varchar,这步会将其转换为枚举类型 -ALTER TABLE "keys" - ALTER COLUMN "daily_reset_mode" TYPE "daily_reset_mode" - USING "daily_reset_mode"::"daily_reset_mode"; ---> statement-breakpoint - -ALTER TABLE "providers" - ALTER COLUMN "daily_reset_mode" TYPE "daily_reset_mode" - USING "daily_reset_mode"::"daily_reset_mode"; diff --git a/drizzle/0023_cheerful_shocker.sql b/drizzle/0023_cheerful_shocker.sql deleted file mode 100644 index c43711aa0..000000000 --- a/drizzle/0023_cheerful_shocker.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE "providers" ALTER COLUMN "streaming_idle_timeout_ms" SET DEFAULT 300000; \ No newline at end of file diff --git a/drizzle/0023_daily_limit_partial_indexes.sql b/drizzle/0023_daily_limit_partial_indexes.sql deleted file mode 100644 index 595d39cb8..000000000 --- a/drizzle/0023_daily_limit_partial_indexes.sql +++ /dev/null @@ -1,12 +0,0 @@ --- 每日成本限额性能优化 - 部分索引 --- 为 keys 和 providers 表的每日限额字段添加部分索引,提升查询性能 - --- 为 keys 表添加部分索引(仅索引配置了每日限额的记录) -CREATE INDEX IF NOT EXISTS "idx_keys_daily_limit" -ON "keys"("limit_daily_usd", "daily_reset_mode") -WHERE "limit_daily_usd" IS NOT NULL;--> statement-breakpoint - --- 为 providers 表添加部分索引(仅索引配置了每日限额的记录) -CREATE INDEX IF NOT EXISTS "idx_providers_daily_limit" -ON "providers"("limit_daily_usd", "daily_reset_mode") -WHERE "limit_daily_usd" IS NOT NULL; diff --git a/drizzle/0023_safe_christian_walker.sql b/drizzle/0023_safe_christian_walker.sql deleted file mode 100644 index afe993ba1..000000000 --- a/drizzle/0023_safe_christian_walker.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE "providers" ADD COLUMN "mcp_passthrough_type" varchar(20) DEFAULT 'none' NOT NULL;--> statement-breakpoint -ALTER TABLE "providers" ADD COLUMN "mcp_passthrough_url" varchar(512); \ No newline at end of file diff --git a/drizzle/0024_update_provider_timeout_defaults.sql b/drizzle/0024_update_provider_timeout_defaults.sql deleted file mode 100644 index 728cb26fb..000000000 --- a/drizzle/0024_update_provider_timeout_defaults.sql +++ /dev/null @@ -1,18 +0,0 @@ --- 修改供应商超时配置默认值为 0(不限制) --- 并批量更新流式静默期超时:小于 60s 的改为 60s - --- 1. 修改默认值为 0(不限制超时) -ALTER TABLE "providers" ALTER COLUMN "first_byte_timeout_streaming_ms" SET DEFAULT 0; -ALTER TABLE "providers" ALTER COLUMN "streaming_idle_timeout_ms" SET DEFAULT 0; -ALTER TABLE "providers" ALTER COLUMN "request_timeout_non_streaming_ms" SET DEFAULT 0; - --- 2. 批量更新流式静默期超时 --- 规则: --- - 小于 60000ms (60s) 且大于 0 的 → 改为 60000 --- - 等于 0(不限制)的 → 不操作 --- - 大于等于 60000 的 → 不操作 -UPDATE "providers" -SET "streaming_idle_timeout_ms" = 60000 -WHERE "streaming_idle_timeout_ms" > 0 - AND "streaming_idle_timeout_ms" < 60000 - AND "deleted_at" IS NULL; diff --git a/drizzle/meta/0020_snapshot.json b/drizzle/meta/0020_snapshot.json index d46e22ddb..6615f0bb2 100644 --- a/drizzle/meta/0020_snapshot.json +++ b/drizzle/meta/0020_snapshot.json @@ -1,5 +1,5 @@ { - "id": "2cca68f8-d8c7-4298-9f24-c8fd493d700e", + "id": "e423d87a-7e70-4a76-b7ad-4011efd95f2a", "prevId": "4ba39e7a-e353-4ed1-8e18-934a56fb0af6", "version": "7", "dialect": "postgresql", @@ -212,7 +212,8 @@ }, "daily_reset_mode": { "name": "daily_reset_mode", - "type": "varchar(10)", + "type": "daily_reset_mode", + "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'fixed'" @@ -954,6 +955,19 @@ "notNull": false, "default": "'auto'" }, + "mcp_passthrough_type": { + "name": "mcp_passthrough_type", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'none'" + }, + "mcp_passthrough_url": { + "name": "mcp_passthrough_url", + "type": "varchar(512)", + "primaryKey": false, + "notNull": false + }, "limit_5h_usd": { "name": "limit_5h_usd", "type": "numeric(10, 2)", @@ -968,7 +982,8 @@ }, "daily_reset_mode": { "name": "daily_reset_mode", - "type": "varchar(10)", + "type": "daily_reset_mode", + "typeSchema": "public", "primaryKey": false, "notNull": true, "default": "'fixed'" @@ -1038,21 +1053,21 @@ "type": "integer", "primaryKey": false, "notNull": true, - "default": 30000 + "default": 0 }, "streaming_idle_timeout_ms": { "name": "streaming_idle_timeout_ms", "type": "integer", "primaryKey": false, "notNull": true, - "default": 10000 + "default": 0 }, "request_timeout_non_streaming_ms": { "name": "request_timeout_non_streaming_ms", "type": "integer", "primaryKey": false, "notNull": true, - "default": 600000 + "default": 0 }, "website_url": { "name": "website_url", @@ -1325,6 +1340,13 @@ "notNull": true, "default": "'USD'" }, + "billing_model_source": { + "name": "billing_model_source", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true, + "default": "'original'" + }, "enable_auto_cleanup": { "name": "enable_auto_cleanup", "type": "boolean", @@ -1545,7 +1567,16 @@ "isRLSEnabled": false } }, - "enums": {}, + "enums": { + "public.daily_reset_mode": { + "name": "daily_reset_mode", + "schema": "public", + "values": [ + "fixed", + "rolling" + ] + } + }, "schemas": {}, "sequences": {}, "roles": {}, @@ -1556,4 +1587,4 @@ "schemas": {}, "tables": {} } -} +} \ No newline at end of file diff --git a/drizzle/meta/0021_snapshot.json b/drizzle/meta/0021_snapshot.json deleted file mode 100644 index 9753cfee5..000000000 --- a/drizzle/meta/0021_snapshot.json +++ /dev/null @@ -1,1526 +0,0 @@ -{ - "id": "a0d7b238-d013-4831-9f8c-02e0532bf035", - "prevId": "2cca68f8-d8c7-4298-9f24-c8fd493d700e", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.error_rules": { - "name": "error_rules", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "pattern": { - "name": "pattern", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'regex'" - }, - "category": { - "name": "category", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_error_rules_enabled": { - "name": "idx_error_rules_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "unique_pattern": { - "name": "unique_pattern", - "columns": [ - { - "expression": "pattern", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_category": { - "name": "idx_category", - "columns": [ - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_match_type": { - "name": "idx_match_type", - "columns": [ - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.keys": { - "name": "keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "can_login_web_ui": { - "name": "can_login_web_ui", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_keys_user_id": { - "name": "idx_keys_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_created_at": { - "name": "idx_keys_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_deleted_at": { - "name": "idx_keys_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.message_request": { - "name": "message_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "duration_ms": { - "name": "duration_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(21, 15)", - "primaryKey": false, - "notNull": false, - "default": "'0'" - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false - }, - "session_id": { - "name": "session_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "provider_chain": { - "name": "provider_chain", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status_code": { - "name": "status_code", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "api_type": { - "name": "api_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "endpoint": { - "name": "endpoint", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "original_model": { - "name": "original_model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_creation_input_tokens": { - "name": "cache_creation_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_read_input_tokens": { - "name": "cache_read_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "blocked_by": { - "name": "blocked_by", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "blocked_reason": { - "name": "blocked_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "messages_count": { - "name": "messages_count", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_message_request_user_date_cost": { - "name": "idx_message_request_user_date_cost", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "cost_usd", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_query": { - "name": "idx_message_request_user_query", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_session_id": { - "name": "idx_message_request_session_id", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_endpoint": { - "name": "idx_message_request_endpoint", - "columns": [ - { - "expression": "endpoint", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_provider_id": { - "name": "idx_message_request_provider_id", - "columns": [ - { - "expression": "provider_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_id": { - "name": "idx_message_request_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_key": { - "name": "idx_message_request_key", - "columns": [ - { - "expression": "key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_created_at": { - "name": "idx_message_request_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_deleted_at": { - "name": "idx_message_request_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.model_prices": { - "name": "model_prices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "model_name": { - "name": "model_name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "price_data": { - "name": "price_data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_model_prices_latest": { - "name": "idx_model_prices_latest", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_model_name": { - "name": "idx_model_prices_model_name", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_created_at": { - "name": "idx_model_prices_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notification_settings": { - "name": "notification_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "enabled": { - "name": "enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_enabled": { - "name": "circuit_breaker_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_webhook": { - "name": "circuit_breaker_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_enabled": { - "name": "daily_leaderboard_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "daily_leaderboard_webhook": { - "name": "daily_leaderboard_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_time": { - "name": "daily_leaderboard_time", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false, - "default": "'09:00'" - }, - "daily_leaderboard_top_n": { - "name": "daily_leaderboard_top_n", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "cost_alert_enabled": { - "name": "cost_alert_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "cost_alert_webhook": { - "name": "cost_alert_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "cost_alert_threshold": { - "name": "cost_alert_threshold", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.80'" - }, - "cost_alert_check_interval": { - "name": "cost_alert_check_interval", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.providers": { - "name": "providers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "weight": { - "name": "weight", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false, - "default": "'1.0'" - }, - "group_tag": { - "name": "group_tag", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "provider_type": { - "name": "provider_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'claude'" - }, - "model_redirects": { - "name": "model_redirects", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "allowed_models": { - "name": "allowed_models", - "type": "jsonb", - "primaryKey": false, - "notNull": false, - "default": "'null'::jsonb" - }, - "join_claude_pool": { - "name": "join_claude_pool", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "codex_instructions_strategy": { - "name": "codex_instructions_strategy", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'auto'" - }, - "mcp_passthrough_type": { - "name": "mcp_passthrough_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'none'" - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "circuit_breaker_failure_threshold": { - "name": "circuit_breaker_failure_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "circuit_breaker_open_duration": { - "name": "circuit_breaker_open_duration", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1800000 - }, - "circuit_breaker_half_open_success_threshold": { - "name": "circuit_breaker_half_open_success_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 2 - }, - "proxy_url": { - "name": "proxy_url", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "proxy_fallback_to_direct": { - "name": "proxy_fallback_to_direct", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "first_byte_timeout_streaming_ms": { - "name": "first_byte_timeout_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 30000 - }, - "streaming_idle_timeout_ms": { - "name": "streaming_idle_timeout_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 10000 - }, - "request_timeout_non_streaming_ms": { - "name": "request_timeout_non_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 600000 - }, - "website_url": { - "name": "website_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "favicon_url": { - "name": "favicon_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tpm": { - "name": "tpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpm": { - "name": "rpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpd": { - "name": "rpd", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "cc": { - "name": "cc", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_providers_enabled_priority": { - "name": "idx_providers_enabled_priority", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "weight", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_group": { - "name": "idx_providers_group", - "columns": [ - { - "expression": "group_tag", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_created_at": { - "name": "idx_providers_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_deleted_at": { - "name": "idx_providers_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sensitive_words": { - "name": "sensitive_words", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "word": { - "name": "word", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'contains'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_sensitive_words_enabled": { - "name": "idx_sensitive_words_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_sensitive_words_created_at": { - "name": "idx_sensitive_words_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.system_settings": { - "name": "system_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "site_title": { - "name": "site_title", - "type": "varchar(128)", - "primaryKey": false, - "notNull": true, - "default": "'Claude Code Hub'" - }, - "allow_global_usage_view": { - "name": "allow_global_usage_view", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "currency_display": { - "name": "currency_display", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true, - "default": "'USD'" - }, - "enable_auto_cleanup": { - "name": "enable_auto_cleanup", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "cleanup_retention_days": { - "name": "cleanup_retention_days", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 30 - }, - "cleanup_schedule": { - "name": "cleanup_schedule", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'0 2 * * *'" - }, - "cleanup_batch_size": { - "name": "cleanup_batch_size", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 10000 - }, - "enable_client_version_check": { - "name": "enable_client_version_check", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false, - "default": "'user'" - }, - "rpm_limit": { - "name": "rpm_limit", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "daily_limit_usd": { - "name": "daily_limit_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false, - "default": "'100.00'" - }, - "provider_group": { - "name": "provider_group", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_users_active_role_sort": { - "name": "idx_users_active_role_sort", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"users\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_created_at": { - "name": "idx_users_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_deleted_at": { - "name": "idx_users_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": {}, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0023_snapshot.json b/drizzle/meta/0023_snapshot.json deleted file mode 100644 index 7cb067c16..000000000 --- a/drizzle/meta/0023_snapshot.json +++ /dev/null @@ -1,1583 +0,0 @@ -{ - "id": "301f797d-6e88-4b88-8cf4-a1ba480ea35c", - "prevId": "8039ff75-655e-4ae6-a4a3-2fd0d285fad7", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.error_rules": { - "name": "error_rules", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "pattern": { - "name": "pattern", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'regex'" - }, - "category": { - "name": "category", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_error_rules_enabled": { - "name": "idx_error_rules_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "unique_pattern": { - "name": "unique_pattern", - "columns": [ - { - "expression": "pattern", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_category": { - "name": "idx_category", - "columns": [ - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_match_type": { - "name": "idx_match_type", - "columns": [ - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.keys": { - "name": "keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "can_login_web_ui": { - "name": "can_login_web_ui", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_daily_usd": { - "name": "limit_daily_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "daily_reset_mode": { - "name": "daily_reset_mode", - "type": "daily_reset_mode", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'fixed'" - }, - "daily_reset_time": { - "name": "daily_reset_time", - "type": "varchar(5)", - "primaryKey": false, - "notNull": true, - "default": "'00:00'" - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_keys_user_id": { - "name": "idx_keys_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_created_at": { - "name": "idx_keys_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_deleted_at": { - "name": "idx_keys_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.message_request": { - "name": "message_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "duration_ms": { - "name": "duration_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(21, 15)", - "primaryKey": false, - "notNull": false, - "default": "'0'" - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false - }, - "session_id": { - "name": "session_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "provider_chain": { - "name": "provider_chain", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status_code": { - "name": "status_code", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "api_type": { - "name": "api_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "endpoint": { - "name": "endpoint", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "original_model": { - "name": "original_model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_creation_input_tokens": { - "name": "cache_creation_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_read_input_tokens": { - "name": "cache_read_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "blocked_by": { - "name": "blocked_by", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "blocked_reason": { - "name": "blocked_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "messages_count": { - "name": "messages_count", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_message_request_user_date_cost": { - "name": "idx_message_request_user_date_cost", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "cost_usd", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_query": { - "name": "idx_message_request_user_query", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_session_id": { - "name": "idx_message_request_session_id", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_endpoint": { - "name": "idx_message_request_endpoint", - "columns": [ - { - "expression": "endpoint", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_provider_id": { - "name": "idx_message_request_provider_id", - "columns": [ - { - "expression": "provider_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_id": { - "name": "idx_message_request_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_key": { - "name": "idx_message_request_key", - "columns": [ - { - "expression": "key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_created_at": { - "name": "idx_message_request_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_deleted_at": { - "name": "idx_message_request_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.model_prices": { - "name": "model_prices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "model_name": { - "name": "model_name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "price_data": { - "name": "price_data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_model_prices_latest": { - "name": "idx_model_prices_latest", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_model_name": { - "name": "idx_model_prices_model_name", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_created_at": { - "name": "idx_model_prices_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notification_settings": { - "name": "notification_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "enabled": { - "name": "enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_enabled": { - "name": "circuit_breaker_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_webhook": { - "name": "circuit_breaker_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_enabled": { - "name": "daily_leaderboard_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "daily_leaderboard_webhook": { - "name": "daily_leaderboard_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_time": { - "name": "daily_leaderboard_time", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false, - "default": "'09:00'" - }, - "daily_leaderboard_top_n": { - "name": "daily_leaderboard_top_n", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "cost_alert_enabled": { - "name": "cost_alert_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "cost_alert_webhook": { - "name": "cost_alert_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "cost_alert_threshold": { - "name": "cost_alert_threshold", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.80'" - }, - "cost_alert_check_interval": { - "name": "cost_alert_check_interval", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.providers": { - "name": "providers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "weight": { - "name": "weight", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false, - "default": "'1.0'" - }, - "group_tag": { - "name": "group_tag", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "provider_type": { - "name": "provider_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'claude'" - }, - "model_redirects": { - "name": "model_redirects", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "allowed_models": { - "name": "allowed_models", - "type": "jsonb", - "primaryKey": false, - "notNull": false, - "default": "'null'::jsonb" - }, - "join_claude_pool": { - "name": "join_claude_pool", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "codex_instructions_strategy": { - "name": "codex_instructions_strategy", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'auto'" - }, - "mcp_passthrough_type": { - "name": "mcp_passthrough_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "mcp_passthrough_url": { - "name": "mcp_passthrough_url", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_daily_usd": { - "name": "limit_daily_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "daily_reset_mode": { - "name": "daily_reset_mode", - "type": "daily_reset_mode", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'fixed'" - }, - "daily_reset_time": { - "name": "daily_reset_time", - "type": "varchar(5)", - "primaryKey": false, - "notNull": true, - "default": "'00:00'" - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "circuit_breaker_failure_threshold": { - "name": "circuit_breaker_failure_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "circuit_breaker_open_duration": { - "name": "circuit_breaker_open_duration", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1800000 - }, - "circuit_breaker_half_open_success_threshold": { - "name": "circuit_breaker_half_open_success_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 2 - }, - "proxy_url": { - "name": "proxy_url", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "proxy_fallback_to_direct": { - "name": "proxy_fallback_to_direct", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "first_byte_timeout_streaming_ms": { - "name": "first_byte_timeout_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 30000 - }, - "streaming_idle_timeout_ms": { - "name": "streaming_idle_timeout_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 300000 - }, - "request_timeout_non_streaming_ms": { - "name": "request_timeout_non_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 600000 - }, - "website_url": { - "name": "website_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "favicon_url": { - "name": "favicon_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tpm": { - "name": "tpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpm": { - "name": "rpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpd": { - "name": "rpd", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "cc": { - "name": "cc", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_providers_enabled_priority": { - "name": "idx_providers_enabled_priority", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "weight", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_group": { - "name": "idx_providers_group", - "columns": [ - { - "expression": "group_tag", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_created_at": { - "name": "idx_providers_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_deleted_at": { - "name": "idx_providers_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sensitive_words": { - "name": "sensitive_words", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "word": { - "name": "word", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'contains'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_sensitive_words_enabled": { - "name": "idx_sensitive_words_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_sensitive_words_created_at": { - "name": "idx_sensitive_words_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.system_settings": { - "name": "system_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "site_title": { - "name": "site_title", - "type": "varchar(128)", - "primaryKey": false, - "notNull": true, - "default": "'Claude Code Hub'" - }, - "allow_global_usage_view": { - "name": "allow_global_usage_view", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "currency_display": { - "name": "currency_display", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true, - "default": "'USD'" - }, - "enable_auto_cleanup": { - "name": "enable_auto_cleanup", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "cleanup_retention_days": { - "name": "cleanup_retention_days", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 30 - }, - "cleanup_schedule": { - "name": "cleanup_schedule", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'0 2 * * *'" - }, - "cleanup_batch_size": { - "name": "cleanup_batch_size", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 10000 - }, - "enable_client_version_check": { - "name": "enable_client_version_check", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false, - "default": "'user'" - }, - "rpm_limit": { - "name": "rpm_limit", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "daily_limit_usd": { - "name": "daily_limit_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false, - "default": "'100.00'" - }, - "provider_group": { - "name": "provider_group", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_users_active_role_sort": { - "name": "idx_users_active_role_sort", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"users\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_created_at": { - "name": "idx_users_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_deleted_at": { - "name": "idx_users_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.daily_reset_mode": { - "name": "daily_reset_mode", - "schema": "public", - "values": [ - "fixed", - "rolling" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/0024_snapshot.json b/drizzle/meta/0024_snapshot.json deleted file mode 100644 index 1fe1fb193..000000000 --- a/drizzle/meta/0024_snapshot.json +++ /dev/null @@ -1,1583 +0,0 @@ -{ - "id": "301f797d-6e88-4b88-8cf4-a1ba480ea35c", - "prevId": "8039ff75-655e-4ae6-a4a3-2fd0d285fad7", - "version": "7", - "dialect": "postgresql", - "tables": { - "public.error_rules": { - "name": "error_rules", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "pattern": { - "name": "pattern", - "type": "text", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'regex'" - }, - "category": { - "name": "category", - "type": "varchar(50)", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "is_default": { - "name": "is_default", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_error_rules_enabled": { - "name": "idx_error_rules_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "unique_pattern": { - "name": "unique_pattern", - "columns": [ - { - "expression": "pattern", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": true, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_category": { - "name": "idx_category", - "columns": [ - { - "expression": "category", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_match_type": { - "name": "idx_match_type", - "columns": [ - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.keys": { - "name": "keys", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "expires_at": { - "name": "expires_at", - "type": "timestamp", - "primaryKey": false, - "notNull": false - }, - "can_login_web_ui": { - "name": "can_login_web_ui", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": true - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_daily_usd": { - "name": "limit_daily_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "daily_reset_mode": { - "name": "daily_reset_mode", - "type": "daily_reset_mode", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'fixed'" - }, - "daily_reset_time": { - "name": "daily_reset_time", - "type": "varchar(5)", - "primaryKey": false, - "notNull": true, - "default": "'00:00'" - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_keys_user_id": { - "name": "idx_keys_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_created_at": { - "name": "idx_keys_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_keys_deleted_at": { - "name": "idx_keys_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.message_request": { - "name": "message_request", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "provider_id": { - "name": "provider_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "user_id": { - "name": "user_id", - "type": "integer", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "model": { - "name": "model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "duration_ms": { - "name": "duration_ms", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cost_usd": { - "name": "cost_usd", - "type": "numeric(21, 15)", - "primaryKey": false, - "notNull": false, - "default": "'0'" - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false - }, - "session_id": { - "name": "session_id", - "type": "varchar(64)", - "primaryKey": false, - "notNull": false - }, - "provider_chain": { - "name": "provider_chain", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "status_code": { - "name": "status_code", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "api_type": { - "name": "api_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false - }, - "endpoint": { - "name": "endpoint", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false - }, - "original_model": { - "name": "original_model", - "type": "varchar(128)", - "primaryKey": false, - "notNull": false - }, - "input_tokens": { - "name": "input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "output_tokens": { - "name": "output_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_creation_input_tokens": { - "name": "cache_creation_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "cache_read_input_tokens": { - "name": "cache_read_input_tokens", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "blocked_by": { - "name": "blocked_by", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "blocked_reason": { - "name": "blocked_reason", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "user_agent": { - "name": "user_agent", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "messages_count": { - "name": "messages_count", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_message_request_user_date_cost": { - "name": "idx_message_request_user_date_cost", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "cost_usd", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_query": { - "name": "idx_message_request_user_query", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_session_id": { - "name": "idx_message_request_session_id", - "columns": [ - { - "expression": "session_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_endpoint": { - "name": "idx_message_request_endpoint", - "columns": [ - { - "expression": "endpoint", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"message_request\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_provider_id": { - "name": "idx_message_request_provider_id", - "columns": [ - { - "expression": "provider_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_user_id": { - "name": "idx_message_request_user_id", - "columns": [ - { - "expression": "user_id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_key": { - "name": "idx_message_request_key", - "columns": [ - { - "expression": "key", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_created_at": { - "name": "idx_message_request_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_message_request_deleted_at": { - "name": "idx_message_request_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.model_prices": { - "name": "model_prices", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "model_name": { - "name": "model_name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "price_data": { - "name": "price_data", - "type": "jsonb", - "primaryKey": false, - "notNull": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_model_prices_latest": { - "name": "idx_model_prices_latest", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_model_name": { - "name": "idx_model_prices_model_name", - "columns": [ - { - "expression": "model_name", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_model_prices_created_at": { - "name": "idx_model_prices_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": false, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.notification_settings": { - "name": "notification_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "enabled": { - "name": "enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_enabled": { - "name": "circuit_breaker_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "circuit_breaker_webhook": { - "name": "circuit_breaker_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_enabled": { - "name": "daily_leaderboard_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "daily_leaderboard_webhook": { - "name": "daily_leaderboard_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "daily_leaderboard_time": { - "name": "daily_leaderboard_time", - "type": "varchar(10)", - "primaryKey": false, - "notNull": false, - "default": "'09:00'" - }, - "daily_leaderboard_top_n": { - "name": "daily_leaderboard_top_n", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "cost_alert_enabled": { - "name": "cost_alert_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "cost_alert_webhook": { - "name": "cost_alert_webhook", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "cost_alert_threshold": { - "name": "cost_alert_threshold", - "type": "numeric(5, 2)", - "primaryKey": false, - "notNull": false, - "default": "'0.80'" - }, - "cost_alert_check_interval": { - "name": "cost_alert_check_interval", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.providers": { - "name": "providers", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "url": { - "name": "url", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "key": { - "name": "key", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "weight": { - "name": "weight", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 1 - }, - "priority": { - "name": "priority", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "cost_multiplier": { - "name": "cost_multiplier", - "type": "numeric(10, 4)", - "primaryKey": false, - "notNull": false, - "default": "'1.0'" - }, - "group_tag": { - "name": "group_tag", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "provider_type": { - "name": "provider_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'claude'" - }, - "model_redirects": { - "name": "model_redirects", - "type": "jsonb", - "primaryKey": false, - "notNull": false - }, - "allowed_models": { - "name": "allowed_models", - "type": "jsonb", - "primaryKey": false, - "notNull": false, - "default": "'null'::jsonb" - }, - "join_claude_pool": { - "name": "join_claude_pool", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "codex_instructions_strategy": { - "name": "codex_instructions_strategy", - "type": "varchar(20)", - "primaryKey": false, - "notNull": false, - "default": "'auto'" - }, - "mcp_passthrough_type": { - "name": "mcp_passthrough_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'none'" - }, - "mcp_passthrough_url": { - "name": "mcp_passthrough_url", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_daily_usd": { - "name": "limit_daily_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "daily_reset_mode": { - "name": "daily_reset_mode", - "type": "daily_reset_mode", - "typeSchema": "public", - "primaryKey": false, - "notNull": true, - "default": "'fixed'" - }, - "daily_reset_time": { - "name": "daily_reset_time", - "type": "varchar(5)", - "primaryKey": false, - "notNull": true, - "default": "'00:00'" - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "circuit_breaker_failure_threshold": { - "name": "circuit_breaker_failure_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 5 - }, - "circuit_breaker_open_duration": { - "name": "circuit_breaker_open_duration", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 1800000 - }, - "circuit_breaker_half_open_success_threshold": { - "name": "circuit_breaker_half_open_success_threshold", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 2 - }, - "proxy_url": { - "name": "proxy_url", - "type": "varchar(512)", - "primaryKey": false, - "notNull": false - }, - "proxy_fallback_to_direct": { - "name": "proxy_fallback_to_direct", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "first_byte_timeout_streaming_ms": { - "name": "first_byte_timeout_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "streaming_idle_timeout_ms": { - "name": "streaming_idle_timeout_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "request_timeout_non_streaming_ms": { - "name": "request_timeout_non_streaming_ms", - "type": "integer", - "primaryKey": false, - "notNull": true, - "default": 0 - }, - "website_url": { - "name": "website_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "favicon_url": { - "name": "favicon_url", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "tpm": { - "name": "tpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpm": { - "name": "rpm", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "rpd": { - "name": "rpd", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "cc": { - "name": "cc", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 0 - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_providers_enabled_priority": { - "name": "idx_providers_enabled_priority", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "priority", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "weight", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_group": { - "name": "idx_providers_group", - "columns": [ - { - "expression": "group_tag", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"providers\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_created_at": { - "name": "idx_providers_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_providers_deleted_at": { - "name": "idx_providers_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.sensitive_words": { - "name": "sensitive_words", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "word": { - "name": "word", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true - }, - "match_type": { - "name": "match_type", - "type": "varchar(20)", - "primaryKey": false, - "notNull": true, - "default": "'contains'" - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": true - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": { - "idx_sensitive_words_enabled": { - "name": "idx_sensitive_words_enabled", - "columns": [ - { - "expression": "is_enabled", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "match_type", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_sensitive_words_created_at": { - "name": "idx_sensitive_words_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.system_settings": { - "name": "system_settings", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "site_title": { - "name": "site_title", - "type": "varchar(128)", - "primaryKey": false, - "notNull": true, - "default": "'Claude Code Hub'" - }, - "allow_global_usage_view": { - "name": "allow_global_usage_view", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "currency_display": { - "name": "currency_display", - "type": "varchar(10)", - "primaryKey": false, - "notNull": true, - "default": "'USD'" - }, - "enable_auto_cleanup": { - "name": "enable_auto_cleanup", - "type": "boolean", - "primaryKey": false, - "notNull": false, - "default": false - }, - "cleanup_retention_days": { - "name": "cleanup_retention_days", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 30 - }, - "cleanup_schedule": { - "name": "cleanup_schedule", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false, - "default": "'0 2 * * *'" - }, - "cleanup_batch_size": { - "name": "cleanup_batch_size", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 10000 - }, - "enable_client_version_check": { - "name": "enable_client_version_check", - "type": "boolean", - "primaryKey": false, - "notNull": true, - "default": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - } - }, - "indexes": {}, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - }, - "public.users": { - "name": "users", - "schema": "", - "columns": { - "id": { - "name": "id", - "type": "serial", - "primaryKey": true, - "notNull": true - }, - "name": { - "name": "name", - "type": "varchar", - "primaryKey": false, - "notNull": true - }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false - }, - "role": { - "name": "role", - "type": "varchar", - "primaryKey": false, - "notNull": false, - "default": "'user'" - }, - "rpm_limit": { - "name": "rpm_limit", - "type": "integer", - "primaryKey": false, - "notNull": false, - "default": 60 - }, - "daily_limit_usd": { - "name": "daily_limit_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false, - "default": "'100.00'" - }, - "provider_group": { - "name": "provider_group", - "type": "varchar(50)", - "primaryKey": false, - "notNull": false - }, - "limit_5h_usd": { - "name": "limit_5h_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_weekly_usd": { - "name": "limit_weekly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_monthly_usd": { - "name": "limit_monthly_usd", - "type": "numeric(10, 2)", - "primaryKey": false, - "notNull": false - }, - "limit_concurrent_sessions": { - "name": "limit_concurrent_sessions", - "type": "integer", - "primaryKey": false, - "notNull": false - }, - "created_at": { - "name": "created_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "updated_at": { - "name": "updated_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false, - "default": "now()" - }, - "deleted_at": { - "name": "deleted_at", - "type": "timestamp with time zone", - "primaryKey": false, - "notNull": false - } - }, - "indexes": { - "idx_users_active_role_sort": { - "name": "idx_users_active_role_sort", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "role", - "isExpression": false, - "asc": true, - "nulls": "last" - }, - { - "expression": "id", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "where": "\"users\".\"deleted_at\" IS NULL", - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_created_at": { - "name": "idx_users_created_at", - "columns": [ - { - "expression": "created_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - }, - "idx_users_deleted_at": { - "name": "idx_users_deleted_at", - "columns": [ - { - "expression": "deleted_at", - "isExpression": false, - "asc": true, - "nulls": "last" - } - ], - "isUnique": false, - "concurrently": false, - "method": "btree", - "with": {} - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": {}, - "uniqueConstraints": {}, - "policies": {}, - "checkConstraints": {}, - "isRLSEnabled": false - } - }, - "enums": { - "public.daily_reset_mode": { - "name": "daily_reset_mode", - "schema": "public", - "values": [ - "fixed", - "rolling" - ] - } - }, - "schemas": {}, - "sequences": {}, - "roles": {}, - "policies": {}, - "views": {}, - "_meta": { - "columns": {}, - "schemas": {}, - "tables": {} - } -} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index 0e3371ee4..3e19e663a 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -145,36 +145,8 @@ { "idx": 20, "version": "7", - "when": 1763465177387, - "tag": "0020_next_juggernaut", - "breakpoints": true - }, - { - "idx": 21, - "version": "7", - "when": 1763823720000, - "tag": "0021_daily_cost_limits", - "breakpoints": true - }, - { - "idx": 22, - "version": "7", - "when": 1763955126094, - "tag": "0023_cheerful_shocker", - "breakpoints": true - }, - { - "idx": 23, - "version": "7", - "when": 1764056229573, - "tag": "0023_safe_christian_walker", - "breakpoints": true - }, - { - "idx": 24, - "version": "7", - "when": 1764206400000, - "tag": "0024_update_provider_timeout_defaults", + "when": 1764210000000, + "tag": "0020_glossy_grandmaster", "breakpoints": true } ] diff --git a/messages/en/dashboard.json b/messages/en/dashboard.json index 95e758d84..0a7ef652c 100644 --- a/messages/en/dashboard.json +++ b/messages/en/dashboard.json @@ -78,7 +78,7 @@ "user": "User", "key": "Key", "provider": "Provider", - "model": "Model", + "model": "Billing Model", "endpoint": "Endpoint", "inputTokens": "Input", "outputTokens": "Output", @@ -147,7 +147,14 @@ "requestModel": "Requested Model", "actualModel": "Actual Call", "billing": "Billing Description", - "billingDescription": "The system prioritizes billing based on the price of the requested model ({original}). If the model is not found in the price list, the price of the actually called model ({current}) is used." + "billingDescription": "The system prioritizes billing based on the price of the requested model ({original}). If the model is not found in the price list, the price of the actually called model ({current}) is used.", + "billingModel": "Billing Model", + "actualModelTooltip": "Actual Model: {model}", + "originalModelTooltip": "Original Model: {model}", + "billingDescription_original": "Current billing mode: Using original model before redirection ({original}) for billing", + "billingDescription_redirected": "Current billing mode: Using actual model after redirection ({current}) for billing", + "billingOriginal": "billing: original", + "billingRedirected": "billing: redirected" }, "errorMessage": "Error Message", "filteredProviders": "Filtered Providers", diff --git a/messages/en/settings.json b/messages/en/settings.json index 433685074..9d1431b4f 100644 --- a/messages/en/settings.json +++ b/messages/en/settings.json @@ -141,6 +141,13 @@ "TWD": "NT$ New Taiwan Dollar (TWD)", "KRW": "₩ South Korean Won (KRW)", "SGD": "S$ Singapore Dollar (SGD)" + }, + "billingModelSource": "Billing Model Source", + "billingModelSourcePlaceholder": "Select billing model source", + "billingModelSourceDesc": "Configure which model to use for billing when model redirection occurs. 'Before Redirection' uses the original model requested by the user, 'After Redirection' uses the actual model called.", + "billingModelSourceOptions": { + "original": "Before Redirection (Original Model)", + "redirected": "After Redirection (Actual Model)" } }, "siteSettings": "Site Parameters", diff --git a/messages/ja/dashboard.json b/messages/ja/dashboard.json index 9f1a4370b..2dcb6c21c 100644 --- a/messages/ja/dashboard.json +++ b/messages/ja/dashboard.json @@ -79,7 +79,7 @@ "user": "ユーザー", "key": "キー", "provider": "プロバイダー", - "model": "モデル", + "model": "課金モデル", "endpoint": "エンドポイント", "inputTokens": "入力", "outputTokens": "出力", @@ -148,7 +148,14 @@ "requestModel": "リクエストモデル", "actualModel": "実際の呼び出し", "billing": "課金説明", - "billingDescription": "システムはリクエストモデル({original})の価格を優先して課金します。価格表にそのモデルが存在しない場合、実際の呼び出しモデル({current})の価格を使用します。" + "billingDescription": "システムはリクエストモデル({original})の価格を優先して課金します。価格表にそのモデルが存在しない場合、実際の呼び出しモデル({current})の価格を使用します。", + "billingModel": "課金モデル", + "actualModelTooltip": "実際のモデル: {model}", + "originalModelTooltip": "元のモデル: {model}", + "billingDescription_original": "現在の課金モード:リダイレクト前の元のモデル({original})で課金", + "billingDescription_redirected": "現在の課金モード:リダイレクト後の実際のモデル({current})で課金", + "billingOriginal": "課金: 元", + "billingRedirected": "課金: 実際" }, "errorMessage": "エラーメッセージ", "providerChain": { diff --git a/messages/ja/settings.json b/messages/ja/settings.json index 7a087c486..184f14a4a 100644 --- a/messages/ja/settings.json +++ b/messages/ja/settings.json @@ -141,6 +141,13 @@ "TWD": "NT$ 新台湾ドル (TWD)", "KRW": "₩ 韓国ウォン (KRW)", "SGD": "S$ シンガポールドル (SGD)" + }, + "billingModelSource": "課金モデルソース", + "billingModelSourcePlaceholder": "課金モデルソースを選択", + "billingModelSourceDesc": "モデルリダイレクト時に課金に使用するモデルを設定します。「リダイレクト前」はユーザーがリクエストした元のモデル、「リダイレクト後」は実際に呼び出されたモデルを使用します。", + "billingModelSourceOptions": { + "original": "リダイレクト前(元のモデル)", + "redirected": "リダイレクト後(実際のモデル)" } }, "siteSettings": "サイトパラメータ", diff --git a/messages/ru/dashboard.json b/messages/ru/dashboard.json index 8190852d1..d247b87cf 100644 --- a/messages/ru/dashboard.json +++ b/messages/ru/dashboard.json @@ -78,7 +78,7 @@ "user": "Пользователь", "key": "Ключ", "provider": "Поставщик", - "model": "Модель", + "model": "Модель тарификации", "endpoint": "Эндпоинт", "inputTokens": "Вход", "outputTokens": "Выход", @@ -147,7 +147,14 @@ "requestModel": "Запрошенная модель", "actualModel": "Фактический вызов", "billing": "Описание тарификации", - "billingDescription": "Система в первую очередь тарифицирует по цене запрошенной модели ({original}). Если эта модель отсутствует в прайс-листе, используется цена фактически вызванной модели ({current})." + "billingDescription": "Система в первую очередь тарифицирует по цене запрошенной модели ({original}). Если эта модель отсутствует в прайс-листе, используется цена фактически вызванной модели ({current}).", + "billingModel": "Модель тарификации", + "actualModelTooltip": "Фактическая модель: {model}", + "originalModelTooltip": "Исходная модель: {model}", + "billingDescription_original": "Текущий режим тарификации: По исходной модели до перенаправления ({original})", + "billingDescription_redirected": "Текущий режим тарификации: По фактической модели после перенаправления ({current})", + "billingOriginal": "оплата: исх.", + "billingRedirected": "оплата: факт." }, "errorMessage": "Сообщение об ошибке", "providerChain": { diff --git a/messages/ru/settings.json b/messages/ru/settings.json index 2819c6123..bbabf814e 100644 --- a/messages/ru/settings.json +++ b/messages/ru/settings.json @@ -141,6 +141,13 @@ "TWD": "NT$ Новый тайваньский доллар (TWD)", "KRW": "₩ Южнокорейская вона (KRW)", "SGD": "S$ Сингапурский доллар (SGD)" + }, + "billingModelSource": "Источник модели для тарификации", + "billingModelSourcePlaceholder": "Выберите источник модели для тарификации", + "billingModelSourceDesc": "Настройте, какую модель использовать для тарификации при перенаправлении модели. «До перенаправления» использует исходную модель, запрошенную пользователем, «После перенаправления» использует фактически вызванную модель.", + "billingModelSourceOptions": { + "original": "До перенаправления (исходная модель)", + "redirected": "После перенаправления (фактическая модель)" } }, "siteSettings": "Параметры сайта", diff --git a/messages/zh-CN/dashboard.json b/messages/zh-CN/dashboard.json index 7a6870899..ab07c666a 100644 --- a/messages/zh-CN/dashboard.json +++ b/messages/zh-CN/dashboard.json @@ -79,7 +79,7 @@ "user": "用户", "key": "密钥", "provider": "供应商", - "model": "模型", + "model": "计费模型", "endpoint": "端点", "inputTokens": "输入", "outputTokens": "输出", @@ -148,7 +148,14 @@ "requestModel": "请求模型", "actualModel": "实际调用", "billing": "计费说明", - "billingDescription": "系统优先使用请求模型({original})的价格计费。如果价格表中不存在该模型,则使用实际调用模型({current})的价格。" + "billingDescription": "系统优先使用请求模型({original})的价格计费。如果价格表中不存在该模型,则使用实际调用模型({current})的价格。", + "billingModel": "计费模型", + "actualModelTooltip": "实际模型: {model}", + "originalModelTooltip": "原始模型: {model}", + "billingDescription_original": "当前计费模式:使用重定向前的原始模型({original})计费", + "billingDescription_redirected": "当前计费模式:使用重定向后的实际模型({current})计费", + "billingOriginal": "计费: 原始", + "billingRedirected": "计费: 实际" }, "errorMessage": "错误信息", "filteredProviders": "被过滤的供应商", diff --git a/messages/zh-CN/settings.json b/messages/zh-CN/settings.json index 4b49530d3..cb47622cb 100644 --- a/messages/zh-CN/settings.json +++ b/messages/zh-CN/settings.json @@ -68,6 +68,13 @@ "currencyDisplay": "货币显示单位", "currencyDisplayPlaceholder": "选择货币单位", "currencyDisplayDesc": "修改后,系统所有页面和 API 接口的金额显示将使用对应的货币符号(仅修改符号,不进行汇率转换)。", + "billingModelSource": "计费模型来源", + "billingModelSourcePlaceholder": "选择计费模型来源", + "billingModelSourceDesc": "配置模型重定向时使用哪个模型进行计费。重定向前使用用户请求的原始模型计费,重定向后使用实际调用的模型计费。", + "billingModelSourceOptions": { + "original": "重定向前(原始模型)", + "redirected": "重定向后(实际模型)" + }, "allowGlobalView": "允许查看全站使用量", "allowGlobalViewDesc": "关闭后,普通用户在仪表盘仅能查看自己密钥的使用统计。", "saveSettings": "保存设置", diff --git a/messages/zh-TW/dashboard.json b/messages/zh-TW/dashboard.json index e27047fbd..a25150ac6 100644 --- a/messages/zh-TW/dashboard.json +++ b/messages/zh-TW/dashboard.json @@ -79,7 +79,7 @@ "user": "使用者", "key": "金鑰", "provider": "供應商", - "model": "模型", + "model": "計費模型", "endpoint": "端點", "inputTokens": "輸入", "outputTokens": "輸出", @@ -148,7 +148,14 @@ "requestModel": "請求模型", "actualModel": "實際呼叫", "billing": "計費說明", - "billingDescription": "系統優先使用請求模型({original})的價格計費。如果價格表中不存在該模型,則使用實際呼叫模型({current})的價格。" + "billingDescription": "系統優先使用請求模型({original})的價格計費。如果價格表中不存在該模型,則使用實際呼叫模型({current})的價格。", + "billingModel": "計費模型", + "actualModelTooltip": "實際模型: {model}", + "originalModelTooltip": "原始模型: {model}", + "billingDescription_original": "目前計費模式:使用重新導向前的原始模型({original})計費", + "billingDescription_redirected": "目前計費模式:使用重新導向後的實際模型({current})計費", + "billingOriginal": "計費: 原始", + "billingRedirected": "計費: 實際" }, "errorMessage": "錯誤訊息", "filteredProviders": "被過濾的供應商", diff --git a/messages/zh-TW/settings.json b/messages/zh-TW/settings.json index 81805ee67..e68f49dcc 100644 --- a/messages/zh-TW/settings.json +++ b/messages/zh-TW/settings.json @@ -141,6 +141,13 @@ "TWD": "NT$ 新台幣 (TWD)", "KRW": "₩ 韓元 (KRW)", "SGD": "S$ 新加坡元 (SGD)" + }, + "billingModelSource": "計費模型來源", + "billingModelSourcePlaceholder": "選擇計費模型來源", + "billingModelSourceDesc": "設定模型重新導向時使用哪個模型進行計費。「重新導向前」使用使用者請求的原始模型計費,「重新導向後」使用實際呼叫的模型計費。", + "billingModelSourceOptions": { + "original": "重新導向前(原始模型)", + "redirected": "重新導向後(實際模型)" } }, "siteSettings": "站台參數", diff --git a/src/actions/dashboard-realtime.ts b/src/actions/dashboard-realtime.ts index 643ffb334..6e61a0b77 100644 --- a/src/actions/dashboard-realtime.ts +++ b/src/actions/dashboard-realtime.ts @@ -7,7 +7,6 @@ import type { ActionResult } from "./types"; // 导入已有的接口和方法 import { getOverviewData, type OverviewData } from "./overview"; -import { getActiveSessions } from "./active-sessions"; import { findDailyLeaderboard, findDailyProviderLeaderboard, diff --git a/src/actions/system-config.ts b/src/actions/system-config.ts index b831611c8..e722979d3 100644 --- a/src/actions/system-config.ts +++ b/src/actions/system-config.ts @@ -28,6 +28,7 @@ export async function saveSystemSettings(formData: { siteTitle?: string; allowGlobalUsageView?: boolean; currencyDisplay?: string; + billingModelSource?: string; enableAutoCleanup?: boolean; cleanupRetentionDays?: number; cleanupSchedule?: string; @@ -45,6 +46,7 @@ export async function saveSystemSettings(formData: { siteTitle: validated.siteTitle?.trim(), allowGlobalUsageView: validated.allowGlobalUsageView, currencyDisplay: validated.currencyDisplay, + billingModelSource: validated.billingModelSource, enableAutoCleanup: validated.enableAutoCleanup, cleanupRetentionDays: validated.cleanupRetentionDays, cleanupSchedule: validated.cleanupSchedule, diff --git a/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx b/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx index 9939d41af..a3d040fa3 100644 --- a/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx +++ b/src/app/[locale]/dashboard/logs/_components/error-details-dialog.tsx @@ -17,6 +17,8 @@ import { AlertCircle, ArrowRight, CheckCircle, ExternalLink, Loader2, Monitor } import type { ProviderChainItem } from "@/types/message"; import { hasSessionMessages } from "@/actions/active-sessions"; import { formatProviderTimeline } from "@/lib/utils/provider-chain-formatter"; +import type { BillingModelSource } from "@/types/system-config"; +import { cn } from "@/lib/utils"; interface ErrorDetailsDialogProps { statusCode: number | null; @@ -30,6 +32,10 @@ interface ErrorDetailsDialogProps { userAgent?: string | null; // User-Agent messagesCount?: number | null; // Messages 数量 endpoint?: string | null; // API 端点 + billingModelSource?: BillingModelSource; // 计费模型来源 + externalOpen?: boolean; // 外部控制弹窗开关 + onExternalOpenChange?: (open: boolean) => void; // 外部控制回调 + scrollToRedirect?: boolean; // 是否滚动到重定向部分 } export function ErrorDetailsDialog({ @@ -44,15 +50,29 @@ export function ErrorDetailsDialog({ userAgent, messagesCount, endpoint, + billingModelSource = "original", + externalOpen, + onExternalOpenChange, + scrollToRedirect, }: ErrorDetailsDialogProps) { const t = useTranslations("dashboard"); const tChain = useTranslations("provider-chain"); - const [open, setOpen] = useState(false); + const [internalOpen, setInternalOpen] = useState(false); const [hasMessages, setHasMessages] = useState(false); const [checkingMessages, setCheckingMessages] = useState(false); + // 支持外部控制和内部控制 + const isControlled = externalOpen !== undefined; + const open = isControlled ? externalOpen : internalOpen; + const setOpen = (value: boolean) => { + if (isControlled) { + onExternalOpenChange?.(value); + } else { + setInternalOpen(value); + } + }; + const isSuccess = statusCode && statusCode >= 200 && statusCode < 300; - const isError = statusCode && (statusCode >= 400 || statusCode < 200); const isInProgress = !statusCode; // 没有状态码表示请求进行中 const isBlocked = !!blockedBy; // 是否被拦截 @@ -89,6 +109,18 @@ export function ErrorDetailsDialog({ } }, [open, sessionId]); + // 滚动到重定向部分 + useEffect(() => { + if (open && scrollToRedirect) { + // 等待 DOM 渲染完成后滚动 + const timer = setTimeout(() => { + const element = document.getElementById('model-redirect-section'); + element?.scrollIntoView({ behavior: 'smooth', block: 'start' }); + }, 100); + return () => clearTimeout(timer); + } + }, [open, scrollToRedirect]); + /** * 根据 HTTP 状态码返回对应的 Badge 样式类名 * 参考:new-api 和 gpt-load 的颜色方案,使用更明显的颜色区分 @@ -290,37 +322,35 @@ export function ErrorDetailsDialog({ {/* 模型重定向信息 */} {originalModel && currentModel && originalModel !== currentModel && ( -
- {originalModel}
-
-
- {currentModel}
-
-
+ {originalModel}
+
+
+ {currentModel}
+
+
+ ({billingModelSource === "original"
+ ? t("logs.details.modelRedirect.billingOriginal")
+ : t("logs.details.modelRedirect.billingRedirected")})
+
{t("currencyDisplayDesc")}
{t("billingModelSourceDesc")}
+