From 8712ba69e6370ba347e6611d8addddcc1bb86eba Mon Sep 17 00:00:00 2001 From: MURAOKA Yusuke Date: Sat, 3 Feb 2024 09:22:21 +0900 Subject: [PATCH] fix selecting dialect (#692) --- cmd/goose/main.go | 9 --------- db.go | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/goose/main.go b/cmd/goose/main.go index c03d33ad2..7d06da25f 100644 --- a/cmd/goose/main.go +++ b/cmd/goose/main.go @@ -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) diff --git a/db.go b/db.go index 95e73dd90..e43a6fe4f 100644 --- a/db.go +++ b/db.go @@ -12,6 +12,8 @@ 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" @@ -19,6 +21,11 @@ func OpenDBWithDriver(driver string, dbstring string) (*sql.DB, error) { 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 {