代码拉取完成,页面将自动刷新
同步操作将从 hidu/mysql-schema-sync 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"flag"
"fmt"
"github.com/hidu/mysql-schema-sync/internal"
"log"
"os"
"strings"
)
var configPath = flag.String("conf", "./config.json", "json config file path")
var sync = flag.Bool("sync", false, "sync shcema change to dest db")
var drop = flag.Bool("drop", false, "drop fields,index,foreign key")
var source = flag.String("source", "", "mysql dsn source,eg: test@(10.10.0.1:3306)/test\n\twhen it is not empty ignore [-conf] param")
var dest = flag.String("dest", "", "mysql dsn dest,eg test@(127.0.0.1:3306)/imis")
var tables = flag.String("tables", "", "table names to check\n\teg : product_base,order_*")
var mailTo = flag.String("mail_to", "", "overwrite config's email.to")
func init() {
log.SetFlags(log.Lshortfile | log.Ldate)
df := flag.Usage
flag.Usage = func() {
df()
fmt.Fprintln(os.Stderr, "")
fmt.Fprintln(os.Stderr, "mysql schema sync tools "+internal.Version)
fmt.Fprintln(os.Stderr, internal.AppURL+"\n")
}
}
var cfg *internal.Config
func main() {
flag.Parse()
if *source == "" {
cfg = internal.LoadConfig(*configPath)
} else {
cfg = new(internal.Config)
cfg.SourceDSN = *source
cfg.DestDSN = *dest
}
cfg.Sync = *sync
cfg.Drop = *drop
if *mailTo != "" && cfg.Email != nil {
cfg.Email.To = *mailTo
}
if cfg.Tables == nil {
cfg.Tables = []string{}
}
if *tables != "" {
_ts := strings.Split(*tables, ",")
for _, _name := range _ts {
_name = strings.TrimSpace(_name)
if _name != "" {
cfg.Tables = append(cfg.Tables, _name)
}
}
}
defer (func() {
if err := recover(); err != nil {
log.Println(err)
cfg.SendMailFail(fmt.Sprintf("%s", err))
log.Fatalln("exit")
}
})()
cfg.Check()
internal.CheckSchemaDiff(cfg)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。