From 7c597a6aa08ff4a552ffbcc235a0694830d6cd36 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Wed, 28 Oct 2026 15:40:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A5=E4=B8=8A=E6=BC=8F=E6=8E=89?= =?UTF-8?q?=E7=9A=84=20schema=20=E7=89=88=E6=9C=AC=E5=8F=B7=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A5=BD=E6=B8=A0=E9=81=93=E6=B7=BB=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit c39c3e7 给 Model 加了 cache_write_price/context_length/supports_* 等列 但没递增 schemaVersion,user_version>=2 的库直接跳过 AutoMigrate, models 表缺新列导致 Create 失败、渠道管理添加模型报缺列错误。 bump 到 3 触发一次迁移补齐列。 --- server/internal/store/db.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/internal/store/db.go b/server/internal/store/db.go index 9774f54..8d51146 100644 --- a/server/internal/store/db.go +++ b/server/internal/store/db.go @@ -16,7 +16,11 @@ import ( // 触发一次 AutoMigrate 并把新版本写入库(SQLite 用 PRAGMA user_version)。 // AutoMigrate 对已有表的列判定不收敛(每次都重建表:CREATE __temp + INSERT SELECT + DROP), // 大表上一次重建数十秒且每次重启重演,所以之后版本未变就直接跳过。 -const schemaVersion = 2 +// +// 注意:c39c3e7 给 Model 加了 cache_write_price/context_length/supports_tools/ +// supports_vision/supports_reasoning 等列并删掉了 display_name,但当时漏改这里, +// 导致已建库的实例永远跳过重迁移、新增模型时 Create 因缺列而失败。这里补到 3 触发一次迁移。 +const schemaVersion = 3 // Open 打开数据库连接并自动迁移。 // 开发默认 SQLite(dsn 支持 file:...?_journal_mode=WAL),生产可切 postgres。