Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
685f2ba
fix: 修复使用记录时间筛选的时区问题
ding113 Nov 25, 2025
be65359
fix: 修复 TagInput 组件输入值在失焦时未保存的问题
ding113 Nov 26, 2025
ef23498
Update error-rules.ts
ding113 Nov 26, 2025
2ab9f62
chore: format code (dev-ef23498)
github-actions[bot] Nov 26, 2025
c171c15
ci: trigger CI after format fix
github-actions[bot] Nov 26, 2025
dbb7ac5
feat: 添加计费模型来源配置功能
ding113 Nov 26, 2025
7458e53
chore: format code (dev-dbb7ac5)
github-actions[bot] Nov 26, 2025
e7fadfb
fix: 恢复被误删的迁移文件,修复迁移链一致性
ding113 Nov 26, 2025
02dcbe2
fix: 修正 0025_hard_violations 迁移的时间戳顺序
ding113 Nov 26, 2025
eb92b9e
fix: 修复数据库迁移冲突,合并 0020-0025 为单一幂等迁移
ding113 Nov 26, 2025
97108df
fix: 修正 0025_hard_violations 迁移的时间戳顺序
ding113 Nov 26, 2025
edad194
fix: 修复模型重定向显示问题并简化 UI
ding113 Nov 26, 2025
7a006d9
fix: 修复供应商统计归属问题(重试切换后统计错误)
ding113 Nov 26, 2025
8f3c2a6
fix: count_tokens 端点错误不计入熔断、不触发供应商切换
ding113 Nov 26, 2025
4176a24
fix: 修复模型重定向 i18n 翻译键路径错误
ding113 Nov 26, 2025
a0336c0
fix: 优化模型重定向指示器,改为只显示图标
ding113 Nov 26, 2025
83d7cf6
chore: 修复 ESLint 警告
ding113 Nov 26, 2025
72b077d
fix: 修复模型重定向在供应商切换时未重置的问题
ding113 Nov 26, 2025
2c58dc3
fix: 优化 cache_control 错误规则正则以匹配 Anthropic API 格式
ding113 Nov 26, 2025
2b49a71
fix: 补充迁移文件中缺失的 limit_daily_usd 和 daily_reset_time 字段
ding113 Nov 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions drizzle/0020_glossy_grandmaster.sql
Original file line number Diff line number Diff line change
@@ -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

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical: Missing billing_model_source column in migration

Why this is a problem: The schema at src/drizzle/schema.ts adds billingModelSource column to system_settings table, and the repository code (src/repository/system-config.ts) queries this field. However, this migration file does not add this column. This will cause database errors for users running this migration:

  • SELECT ... billing_model_source ... will fail with "column does not exist"
  • INSERT statements including this field will fail

Suggested fix: Add this line after Step 5 in the migration:

-- Step 5.1: 添加 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;
4 changes: 0 additions & 4 deletions drizzle/0020_next_juggernaut.sql

This file was deleted.

45 changes: 0 additions & 45 deletions drizzle/0021_daily_cost_limits.sql

This file was deleted.

1 change: 0 additions & 1 deletion drizzle/0023_cheerful_shocker.sql

This file was deleted.

12 changes: 0 additions & 12 deletions drizzle/0023_daily_limit_partial_indexes.sql

This file was deleted.

2 changes: 0 additions & 2 deletions drizzle/0023_safe_christian_walker.sql

This file was deleted.

18 changes: 0 additions & 18 deletions drizzle/0024_update_provider_timeout_defaults.sql

This file was deleted.

47 changes: 39 additions & 8 deletions drizzle/meta/0020_snapshot.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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'"
Expand Down Expand Up @@ -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)",
Expand All @@ -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'"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1545,7 +1567,16 @@
"isRLSEnabled": false
}
},
"enums": {},
"enums": {
"public.daily_reset_mode": {
"name": "daily_reset_mode",
"schema": "public",
"values": [
"fixed",
"rolling"
]
}
},
"schemas": {},
"sequences": {},
"roles": {},
Expand All @@ -1556,4 +1587,4 @@
"schemas": {},
"tables": {}
}
}
}
Loading
Loading