Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(cli): postgres not support (#1172)

qsliu0e55c8e50dfb
diff --git a/bin/bb/cmd/dump.go b/bin/bb/cmd/dump.go
index d4c99515a8..42dbcd987e 100644
--- a/bin/bb/cmd/dump.go
+++ b/bin/bb/cmd/dump.go
@@ -7,11 +7,8 @@ import (
"io"
"os"
- "github.com/xo/dburl"
-
- // install mysql driver.
- _ "github.com/bytebase/bytebase/plugin/db/mysql"
"github.com/spf13/cobra"
+ "github.com/xo/dburl"
)
func newDumpCmd() *cobra.Command {
diff --git a/bin/bb/cmd/migrate.go b/bin/bb/cmd/migrate.go
index bbfbab78e3..20d4ecbc7e 100644
--- a/bin/bb/cmd/migrate.go
+++ b/bin/bb/cmd/migrate.go
@@ -11,11 +11,8 @@ import (
"github.com/bytebase/bytebase/common"
"github.com/bytebase/bytebase/plugin/db"
- "github.com/xo/dburl"
-
- // install mysql driver.
- _ "github.com/bytebase/bytebase/plugin/db/mysql"
"github.com/spf13/cobra"
+ "github.com/xo/dburl"
)
func newMigrateCmd() *cobra.Command {
diff --git a/bin/bb/cmd/utils.go b/bin/bb/cmd/utils.go
index 18289aed1f..be5d16461b 100644
--- a/bin/bb/cmd/utils.go
+++ b/bin/bb/cmd/utils.go
@@ -5,6 +5,10 @@ import (
"fmt"
"github.com/bytebase/bytebase/plugin/db"
+ // install mysql driver.
+ _ "github.com/bytebase/bytebase/plugin/db/mysql"
+ // install pg driver.
+ _ "github.com/bytebase/bytebase/plugin/db/pg"
"github.com/xo/dburl"
"go.uber.org/zap"
)
@@ -21,7 +25,9 @@ func open(ctx context.Context, logger *zap.Logger, u *dburl.URL) (db.Driver, err
switch u.Driver {
case "mysql":
dbType = db.MySQL
- case "pg":
+ // dburl.Parse() do the job of parsing 'pg', 'postgresql' and 'pgsql' to 'postgres'.
+ // https://pkg.go.dev/github.com/xo/[email protected]#hdr-Protocol_Schemes_and_Aliases
+ case "postgres":
dbType = db.Postgres
default:
return nil, fmt.Errorf("database type %q not supported; supported types: mysql, pg", u.Driver)