1 Star 0 Fork 0

xx/private-mysql-schema-sync

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
alter.go 1008 Bytes
一键复制 编辑 原始数据 按行查看 历史
package dbsync
import (
"fmt"
"strings"
)
type alterType int
const (
alterTypeNo alterType = iota
alterTypeCreate
alterTypeDrop
alterTypeAlter
)
func (at alterType) String() string {
switch at {
case alterTypeNo:
return "not_change"
case alterTypeCreate:
return "create"
case alterTypeDrop:
return "drop"
case alterTypeAlter:
return "alter"
default:
return "unknown"
}
}
// TableAlterData 表的变更情况
type TableAlterData struct {
Table string
Type alterType
SQL []string
SchemaDiff *SchemaDiff
}
func (ta *TableAlterData) String() string {
relationTables := ta.SchemaDiff.RelationTables()
fmtStr := `
-- Table : %s
-- Type : %s
-- RelationTables : %s
-- SQL :
%s
`
var sqls []string
for _, sql := range ta.SQL {
if strings.TrimSpace(sql) != "" {
sqls = append(sqls, sql)
}
}
sql := ""
if len(sqls) > 0 {
sql = strings.Join(sqls, "\n")
}
return fmt.Sprintf(fmtStr, ta.Table, ta.Type, strings.Join(relationTables, ","), sql)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ankisme/private-mysql-schema-sync.git
git@gitee.com:ankisme/private-mysql-schema-sync.git
ankisme
private-mysql-schema-sync
private-mysql-schema-sync
v0.0.6

搜索帮助