-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
43 lines (38 loc) · 799 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"log"
)
func main() {
// read config.
conf, err := ParseArgs()
if err != nil {
log.Fatal(err)
}
// open source db
srcDB := &DB{}
if err := srcDB.Open(conf.Source); err != nil {
log.Fatal(err, conf.Source)
}
defer srcDB.Close()
if conf.DiffType == "schema" || conf.DiffType == "data" {
// open target db
dstDB := &DB{}
if err := dstDB.Open(conf.Target); err != nil {
log.Fatal(err, conf.Target)
}
defer dstDB.Close()
var isUpdate bool
if conf.DiffType == "schema" {
isUpdate = SchemaDiff(srcDB, dstDB, conf)
} else {
isUpdate = DataDiff(srcDB, dstDB, conf)
}
if isUpdate {
log.Printf("Generated Update Script..%s!\n", conf.Output)
} else {
log.Println("Not Found Diff! ..BYE~!")
}
} else {
MakeDoc(srcDB, conf)
}
}