forked from vmware-archive/pg2mysql
/
verify.go
47 lines (39 loc) · 1.01 KB
/
verify.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
44
45
46
47
package commands
import (
"fmt"
"github.com/pivotal-cf/pg2mysql"
)
type VerifyCommand struct{}
func (c *VerifyCommand) Execute([]string) error {
mysql := pg2mysql.NewMySQLDB(
PG2MySQL.Config.MySQL.Database,
PG2MySQL.Config.MySQL.Username,
PG2MySQL.Config.MySQL.Password,
PG2MySQL.Config.MySQL.Host,
PG2MySQL.Config.MySQL.Port,
)
err := mysql.Open()
if err != nil {
return fmt.Errorf("failed to open mysql connection: %s", err)
}
defer mysql.Close()
pg := pg2mysql.NewPostgreSQLDB(
PG2MySQL.Config.PostgreSQL.Database,
PG2MySQL.Config.PostgreSQL.Username,
PG2MySQL.Config.PostgreSQL.Password,
PG2MySQL.Config.PostgreSQL.Host,
PG2MySQL.Config.PostgreSQL.Port,
PG2MySQL.Config.PostgreSQL.SSLMode,
)
err = pg.Open()
if err != nil {
return fmt.Errorf("failed to open pg connection: %s", err)
}
defer pg.Close()
watcher := pg2mysql.NewStdoutPrinter()
err = pg2mysql.NewVerifier(pg, mysql, watcher).Verify()
if err != nil {
return fmt.Errorf("failed to verify: %s", err)
}
return nil
}