EasyVQD/domain/version/versionapi/api.go

31 lines
573 B
Go
Raw Normal View History

2026-01-15 19:32:33 +08:00
package versionapi
import (
"log/slog"
"easyvqd/domain/version"
"easyvqd/domain/version/store/versiondb"
"git.lnton.com/lnton/pkg/orm"
"gorm.io/gorm"
)
// 通过修改版本号,来控制是否执行表迁移
var (
2026-03-26 10:23:31 +08:00
DBVersion = "0.0.22"
DBRemark = "添加轮询表"
2026-01-15 19:32:33 +08:00
)
// NewVersionCore ...
func NewVersionCore(db *gorm.DB) version.Core {
vdb := versiondb.NewDB(db)
core := version.NewCore(vdb)
isOK := core.IsAutoMigrate(DBVersion)
vdb.AutoMigrate(isOK)
if isOK {
slog.Info("更新数据库表结构")
}
orm.SetEnabledAutoMigrate(isOK)
return core
}