Skip to content

Commit

Permalink
fix selecting dialect (#692)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbking authored Feb 3, 2024
1 parent 81fb552 commit 8712ba6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 0 additions & 9 deletions cmd/goose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,6 @@ func main() {
}

driver, dbstring, command := args[0], args[1], args[2]
// To avoid breaking existing consumers. An implementation detail
// that consumers should not care which underlying driver is used.
switch driver {
case "sqlite3":
// Internally uses the CGo-free port of SQLite: modernc.org/sqlite
driver = "sqlite"
case "postgres", "redshift":
driver = "pgx"
}
db, err := goose.OpenDBWithDriver(driver, normalizeDBString(driver, dbstring, *certfile, *sslcert, *sslkey))
if err != nil {
log.Fatalf("-dbstring=%q: %v\n", dbstring, err)
Expand Down
7 changes: 7 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ func OpenDBWithDriver(driver string, dbstring string) (*sql.DB, error) {
return nil, err
}

// To avoid breaking existing consumers. An implementation detail
// that consumers should not care which underlying driver is used.
switch driver {
case "mssql":
driver = "sqlserver"
case "tidb":
driver = "mysql"
case "turso":
driver = "libsql"
case "sqlite3":
// Internally uses the CGo-free port of SQLite: modernc.org/sqlite
driver = "sqlite"
case "postgres", "redshift":
driver = "pgx"
}

switch driver {
Expand Down

0 comments on commit 8712ba6

Please sign in to comment.