mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-12 16:10:03 +01:00
Add default port for mysql connections (#13)
The pq driver already supports this natively, but the mysql driver does not. This commit adds a default port 3306 for mysql connections.
This commit is contained in:
parent
e393f387b3
commit
9029bbbe3d
2 changed files with 26 additions and 1 deletions
7
mysql.go
7
mysql.go
|
|
@ -16,6 +16,13 @@ type MySQLDriver struct {
|
|||
func normalizeMySQLURL(u *url.URL) string {
|
||||
normalizedURL := *u
|
||||
normalizedURL.Scheme = ""
|
||||
|
||||
// set default port
|
||||
if normalizedURL.Port() == "" {
|
||||
normalizedURL.Host = fmt.Sprintf("%s:3306", normalizedURL.Host)
|
||||
}
|
||||
|
||||
// host format required by go-sql-driver/mysql
|
||||
normalizedURL.Host = fmt.Sprintf("tcp(%s)", normalizedURL.Host)
|
||||
|
||||
query := normalizedURL.Query()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue