mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	数据库升级时表名不区分大小写/增加一些注释
This commit is contained in:
		@@ -52,9 +52,8 @@ import (
 | 
				
			|||||||
	"github.com/iwind/TeaGo/logs"
 | 
						"github.com/iwind/TeaGo/logs"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 最新的SQL语句
 | 
					// 最新版本的数据库SQL语句,用来对比并升级已有的数据库
 | 
				
			||||||
// 由sql-dump/main.go自动生成
 | 
					// 由 sql-dump/main.go 自动生成
 | 
				
			||||||
 | 
					 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	err := json.Unmarshal([]byte(` + strconv.Quote(string(resultsJSON)) + `), LatestSQLResult)
 | 
						err := json.Unmarshal([]byte(` + strconv.Quote(string(resultsJSON)) + `), LatestSQLResult)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -34,7 +34,7 @@ func NewSQLDump() *SQLDump {
 | 
				
			|||||||
	return &SQLDump{}
 | 
						return &SQLDump{}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 导出数据
 | 
					// Dump 导出数据
 | 
				
			||||||
func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
 | 
					func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
 | 
				
			||||||
	result = &SQLDumpResult{}
 | 
						result = &SQLDumpResult{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -107,7 +107,7 @@ func (this *SQLDump) Dump(db *dbs.DB) (result *SQLDumpResult, err error) {
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// 应用数据
 | 
					// Apply 应用数据
 | 
				
			||||||
func (this *SQLDump) Apply(db *dbs.DB, newResult *SQLDumpResult) (ops []string, err error) {
 | 
					func (this *SQLDump) Apply(db *dbs.DB, newResult *SQLDumpResult) (ops []string, err error) {
 | 
				
			||||||
	currentResult, err := this.Dump(db)
 | 
						currentResult, err := this.Dump(db)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,12 +1,14 @@
 | 
				
			|||||||
package setup
 | 
					package setup
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import "strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type SQLDumpResult struct {
 | 
					type SQLDumpResult struct {
 | 
				
			||||||
	Tables []*SQLTable `json:"tables"`
 | 
						Tables []*SQLTable `json:"tables"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (this *SQLDumpResult) FindTable(tableName string) *SQLTable {
 | 
					func (this *SQLDumpResult) FindTable(tableName string) *SQLTable {
 | 
				
			||||||
	for _, table := range this.Tables {
 | 
						for _, table := range this.Tables {
 | 
				
			||||||
		if table.Name == tableName {
 | 
							if strings.ToLower(table.Name) == strings.ToLower(tableName) {
 | 
				
			||||||
			return table
 | 
								return table
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user