安装时检查数据库版本

This commit is contained in:
GoEdgeLab
2020-11-24 08:38:19 +08:00
parent 5c68607583
commit e50ddb95f3
3 changed files with 21 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/dbs"
"github.com/iwind/TeaGo/maps"
stringutil "github.com/iwind/TeaGo/utils/string"
"strings"
)
@@ -65,6 +66,19 @@ func (this *ValidateDbAction) RunPost(params struct {
}
}
// 检查数据库版本
one, err := db.FindOne("SELECT VERSION() AS v")
if err != nil {
this.Fail("检查数据库版本时出错:" + err.Error())
}
if one == nil {
this.Fail("检查数据库版本时出错:无法获取数据库版本")
}
version := one.GetString("v")
if stringutil.VersionCompare(version, "5.7.8") < 0 {
this.Fail("数据库版本至少在v5.7.8以上你现在使用的是v" + version)
}
this.Data["db"] = maps.Map{
"host": params.Host,
"port": params.Port,