数据库升级时表名不区分大小写/增加一些注释

This commit is contained in:
GoEdgeLab
2021-04-18 16:32:08 +08:00
parent 0d97f52551
commit ee2e9527eb
4 changed files with 10 additions and 10 deletions

View File

@@ -52,9 +52,8 @@ import (
"github.com/iwind/TeaGo/logs"
)
// 最新的SQL语句
// 最新版本的数据库SQL语句用来对比并升级已有的数据库
// 由 sql-dump/main.go 自动生成
func init() {
err := json.Unmarshal([]byte(` + strconv.Quote(string(resultsJSON)) + `), LatestSQLResult)
if err != nil {

File diff suppressed because one or more lines are too long

View File

@@ -34,7 +34,7 @@ func NewSQLDump() *SQLDump {
return &SQLDump{}
}
// 导出数据
// Dump 导出数据
func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
result = &SQLDumpResult{}
@@ -107,7 +107,7 @@ func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
return
}
// 应用数据
// Apply 应用数据
func (this *SQLDump) Apply(db *dbs.DB, newResult *SQLDumpResult) (ops []string, err error) {
currentResult, err := this.Dump(db)
if err != nil {

View File

@@ -1,12 +1,14 @@
package setup
import "strings"
type SQLDumpResult struct {
Tables []*SQLTable `json:"tables"`
}
func (this *SQLDumpResult) FindTable(tableName string) *SQLTable {
for _, table := range this.Tables {
if table.Name == tableName {
if strings.ToLower(table.Name) == strings.ToLower(tableName) {
return table
}
}