Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat: enhance system information display with database version
wizardchenaefa1c6fe896
diff --git a/.air.toml b/.air.tomlindex 8a7afb912..4e2e9398a 100644--- a/.air.toml+++ b/.air.toml@@ -5,7 +5,7 @@ tmp_dir = "tmp"[build]args_bin = []bin = "./tmp/main"- cmd = "CGO_CFLAGS='-Wno-deprecated-declarations -Wno-gnu-folding-constant' CGO_LDFLAGS='-Wl,-no_warn_duplicate_libraries' go build -ldflags=\"-X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'\" -o ./tmp/main ./cmd/server"+ cmd = "CGO_CFLAGS='-Wno-deprecated-declarations -Wno-gnu-folding-constant' CGO_LDFLAGS='-Wl,-no_warn_duplicate_libraries' go build -ldflags=\"$(./scripts/get_version.sh ldflags) -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'\" -o ./tmp/main ./cmd/server"delay = 1000exclude_dir = ["assets", "tmp", "vendor", "testdata", "frontend", "migrations", "node_modules", "docs"]exclude_file = []diff --git a/frontend/src/api/system/index.ts b/frontend/src/api/system/index.tsindex 4c18d8c2a..3fe63fcd3 100644--- a/frontend/src/api/system/index.ts+++ b/frontend/src/api/system/index.ts@@ -10,6 +10,7 @@ export interface SystemInfo {vector_store_engine?: stringgraph_database_engine?: stringminio_enabled?: boolean+ db_version?: string}export interface ToolDefinition {diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex d13cd223f..73120b2a1 100755--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -1698,6 +1698,8 @@ export default {buildTimeDescription: 'Time when the system was built',goVersionLabel: 'Go Version',goVersionDescription: 'Go language version used by the backend',+ dbVersionLabel: 'Database Version',+ dbVersionDescription: 'Current database migration version',keywordIndexEngineLabel: 'Keyword Index Engine',keywordIndexEngineDescription: 'Currently used keyword index engine',vectorStoreEngineLabel: 'Vector Store Engine',diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.tsindex a57e4df89..101a468be 100755--- a/frontend/src/i18n/locales/ko-KR.ts+++ b/frontend/src/i18n/locales/ko-KR.ts@@ -1194,6 +1194,8 @@ export default {buildTimeDescription: "시스템이 빌드된 시간",goVersionLabel: "Go 버전",goVersionDescription: "백엔드에서 사용하는 Go 언어 버전",+ dbVersionLabel: "데이터베이스 버전",+ dbVersionDescription: "현재 데이터베이스 마이그레이션 버전",keywordIndexEngineLabel: "키워드 인덱스 엔진",keywordIndexEngineDescription: "현재 사용 중인 키워드 인덱스 엔진",vectorStoreEngineLabel: "벡터 저장소 엔진",diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 6a4f0b9fd..c8b37f6bc 100755--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -815,6 +815,8 @@ export default {buildTimeDescription: 'Время, когда система была собрана',goVersionLabel: 'Версия Go',goVersionDescription: 'Версия языка Go, используемая backend',+ dbVersionLabel: 'Версия базы данных',+ dbVersionDescription: 'Текущая версия миграции базы данных',keywordIndexEngineLabel: 'Движок индексации ключевых слов',keywordIndexEngineDescription: 'Используемый в настоящее время движок индексации ключевых слов',vectorStoreEngineLabel: 'Движок векторного хранилища',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 02bf576ea..ed9521fcf 100755--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -1174,6 +1174,8 @@ export default {buildTimeDescription: "系统构建的时间",goVersionLabel: "Go 版本",goVersionDescription: "后端使用的 Go 语言版本",+ dbVersionLabel: "数据库版本",+ dbVersionDescription: "当前数据库迁移版本号",keywordIndexEngineLabel: "关键词索引引擎",keywordIndexEngineDescription: "当前使用的关键词索引引擎",vectorStoreEngineLabel: "向量存储引擎",diff --git a/frontend/src/views/settings/SystemInfo.vue b/frontend/src/views/settings/SystemInfo.vueindex 07b72cbe1..95fb69918 100644--- a/frontend/src/views/settings/SystemInfo.vue+++ b/frontend/src/views/settings/SystemInfo.vue@@ -67,6 +67,17 @@</div></div>+ <!-- DB Version -->+ <div v-if="systemInfo?.db_version" class="setting-row">+ <div class="setting-info">+ <label>{{ $t('system.dbVersionLabel') }}</label>+ <p class="desc">{{ $t('system.dbVersionDescription') }}</p>+ </div>+ <div class="setting-control">+ <span class="info-value">{{ systemInfo.db_version }}</span>+ </div>+ </div>+<!-- Keyword Index Engine --><div class="setting-row"><div class="setting-info">diff --git a/internal/database/migration.go b/internal/database/migration.goindex f8f4ec35a..5c836b2ef 100644--- a/internal/database/migration.go+++ b/internal/database/migration.go@@ -5,6 +5,7 @@ import ("fmt""os""strings"+ "sync""github.com/Tencent/WeKnora/internal/logger""github.com/golang-migrate/migrate/v4"@@ -13,6 +14,27 @@ import (_ "github.com/golang-migrate/migrate/v4/source/file")+var (+ currentMigrationVersion uint+ currentMigrationDirty bool+ migrationVersionOnce sync.Once+ migrationVersionSet bool+)++// CachedMigrationVersion returns the migration version captured at startup.+// Returns (version, dirty, ok). ok is false if the version was never captured.+func CachedMigrationVersion() (uint, bool, bool) {+ return currentMigrationVersion, currentMigrationDirty, migrationVersionSet+}++func setMigrationVersion(version uint, dirty bool) {+ migrationVersionOnce.Do(func() {+ currentMigrationVersion = version+ currentMigrationDirty = dirty+ migrationVersionSet = true+ })+}+// RunMigrations executes all pending database migrations// This should be called during application startupfunc RunMigrations(dsn string) error {@@ -142,6 +164,8 @@ func RunMigrationsWithOptions(dsn string, opts MigrationOptions) error {return fmt.Errorf("failed to get migration version: %w", err)}+ setMigrationVersion(version, dirty)+if oldVersion != version {logger.Infof(ctx, "Database migrated from version %d to %d", oldVersion, version)} else {diff --git a/internal/handler/system.go b/internal/handler/system.goindex 7725dde78..ab52d5ee9 100644--- a/internal/handler/system.go+++ b/internal/handler/system.go@@ -11,6 +11,7 @@ import ("github.com/Tencent/WeKnora/internal/application/service/file""github.com/Tencent/WeKnora/internal/config"+ "github.com/Tencent/WeKnora/internal/database""github.com/Tencent/WeKnora/internal/infrastructure/docparser""github.com/Tencent/WeKnora/internal/logger""github.com/Tencent/WeKnora/internal/types"@@ -48,6 +49,7 @@ type GetSystemInfoResponse struct {VectorStoreEngine string `json:"vector_store_engine,omitempty"`GraphDatabaseEngine string `json:"graph_database_engine,omitempty"`MinioEnabled bool `json:"minio_enabled,omitempty"`+ DBVersion string `json:"db_version,omitempty"`}// 编译时注入的版本信息@@ -82,6 +84,14 @@ func (h *SystemHandler) GetSystemInfo(c *gin.Context) {// Get MinIO enabled statusminioEnabled := h.isMinioConfigured(c)+ var dbVersion string+ if ver, dirty, ok := database.CachedMigrationVersion(); ok {+ dbVersion = fmt.Sprintf("%d", ver)+ if dirty {+ dbVersion += " (dirty)"+ }+ }+response := GetSystemInfoResponse{Version: Version,Edition: Edition,@@ -92,6 +102,7 @@ func (h *SystemHandler) GetSystemInfo(c *gin.Context) {VectorStoreEngine: vectorStoreEngine,GraphDatabaseEngine: graphDatabaseEngine,MinioEnabled: minioEnabled,+ DBVersion: dbVersion,}logger.Info(ctx, "System info retrieved successfully")diff --git a/scripts/dev.sh b/scripts/dev.shindex ec21f62cc..2b750cb17 100755--- a/scripts/dev.sh+++ b/scripts/dev.sh@@ -282,7 +282,8 @@ start_app() {log_info "未检测到 Air,使用普通模式启动"log_warning "提示: 安装 Air 可以实现代码修改后自动重启"log_info "安装命令: go install github.com/air-verse/air@latest"- go run -ldflags="-X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'" cmd/server/main.go+ LDFLAGS="$(./scripts/get_version.sh ldflags) -X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"+ go run -ldflags="$LDFLAGS" cmd/server/main.gofi}