Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commands/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func (c *MigrateCommand) Execute([]string) error {
PG2MySQL.Config.MySQL.Password,
PG2MySQL.Config.MySQL.Host,
PG2MySQL.Config.MySQL.Port,
PG2MySQL.Config.MySQL.Charset,
PG2MySQL.Config.MySQL.Collation,
)

err := mysql.Open()
Expand Down
2 changes: 2 additions & 0 deletions commands/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func (c *ValidateCommand) Execute([]string) error {
PG2MySQL.Config.MySQL.Password,
PG2MySQL.Config.MySQL.Host,
PG2MySQL.Config.MySQL.Port,
PG2MySQL.Config.MySQL.Charset,
PG2MySQL.Config.MySQL.Collation,
)

err := mysql.Open()
Expand Down
2 changes: 2 additions & 0 deletions commands/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ func (c *VerifyCommand) Execute([]string) error {
PG2MySQL.Config.MySQL.Password,
PG2MySQL.Config.MySQL.Host,
PG2MySQL.Config.MySQL.Port,
PG2MySQL.Config.MySQL.Charset,
PG2MySQL.Config.MySQL.Collation,
)

err := mysql.Open()
Expand Down
12 changes: 7 additions & 5 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package pg2mysql

type Config struct {
MySQL struct {
Database string `yaml:"database"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Database string `yaml:"database"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Charset string `yaml:"charset"`
Collation string `yaml:"collation"`
} `yaml:"mysql"`

PostgreSQL struct {
Expand Down
13 changes: 12 additions & 1 deletion mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@ func NewMySQLDB(
password string,
host string,
port int,
charset string,
collation string,
) DB {
if (charset == "") {
charset = "utf8"
}

if (collation == "") {
collation = "utf8_general_ci"
}

config := mysql.Config{
User: username,
Passwd: password,
Expand All @@ -22,7 +32,8 @@ func NewMySQLDB(
Addr: fmt.Sprintf("%s:%d", host, port),
MultiStatements: true,
Params: map[string]string{
"charset": "utf8",
"charset": charset,
"collation": collation,
"parseTime": "True",
},
}
Expand Down