Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix selecting dialect #692

Merged
merged 1 commit into from
Feb 3, 2024
Merged
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
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
Loading