feat: 新增日志中心、功能优化与代码重构
- 新增 log_datasource.go / log_proxy.go / user_api_token.go 后端控制器 - 新增 log_datasource.go model - 新增 monitor/log-center.ts API 模块 - 新增 LogCenter 前端组件及页面 - 重构 deployment 相关组件 (HPDA/UpdateImageModal/bundle-yaml 等) - 新增 ResetPasswordDialog / code-snippet-block / copy-button 等 UI 组件 - 重构多个 k8s 相关组件 (TopologyView/ResourceVisualEditor/PodFileBrowser 等) - 更新多个 API 和工具函数 (auth.ts/monitor/index.ts/request.ts 等) - 更新静态资源 (index.html + 新 JS/CSS bundle) - 删除废弃静态资源文件
This commit is contained in:
1 parent
5ca0e6d83a
commit
8d46e8f352
197 files changed
+5014
-815
No files matched your search
@@ -2,6 +2,7 @@ package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -134,6 +135,7 @@ func AutoMigrate(db *gorm.DB) error {
|
||||
&model.SiteAlert{}, // 拨测告警 // Logan.Li
|
||||
&model.PrometheusDataSource{}, // Prometheus 数据源配置 // Logan.Li
|
||||
&model.ZabbixDataSource{}, // Zabbix 数据源配置 // Logan.Li
|
||||
&model.LogDataSource{}, // Loki / ES 日志数据源 // Logan.Li
|
||||
&model.Credential{}, // 凭据管理(SSH密钥/API Token) // Logan.Li
|
||||
&model.PipelineRepo{}, // Git 仓库认证 // Logan.Li
|
||||
&model.PipelineRegistry{}, // 镜像仓库认证 // Logan.Li
|
||||
@@ -164,5 +166,26 @@ func AutoMigrate(db *gorm.DB) error {
|
||||
}
|
||||
// 全部跑完后返回 nil:单张表的索引错误不应阻断服务启动
|
||||
_ = lastErr
|
||||
applySchemaPatches(db)
|
||||
return nil
|
||||
}
|
||||
|
||||
// applySchemaPatches 补全 AutoMigrate 可能遗漏的列(MySQL 索引冲突时 User 表不会自动加列)// Logan.Li
|
||||
func applySchemaPatches(db *gorm.DB) {
|
||||
m := db.Migrator()
|
||||
if !m.HasTable(&model.User{}) {
|
||||
return
|
||||
}
|
||||
patchUserColumn := func(field string, col string) {
|
||||
if !m.HasColumn(&model.User{}, col) {
|
||||
if err := m.AddColumn(&model.User{}, field); err != nil {
|
||||
log.Printf("[DB] 补列 %s 失败: %v", col, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
patchUserColumn("ApiAccessKeyExpiresAt", "api_access_key_expires_at")
|
||||
patchUserColumn("ApiAccessKeyID", "api_access_key_id")
|
||||
patchUserColumn("ApiAccessKeyDescription", "api_access_key_description")
|
||||
patchUserColumn("ApiAccessKeyDurationMonths", "api_access_key_duration_months")
|
||||
patchUserColumn("ApiAccessKeyLastUsedAt", "api_access_key_last_used_at")
|
||||
}
|
||||
Reference in new issue
Block a user