Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: cleanup bytebase database usage (#5450)
Danny Xu2c9eed4d03a0
diff --git a/backend/migrator/migrator.go b/backend/migrator/migrator.goindex a75c05ec2d..29c5233cd3 100644--- a/backend/migrator/migrator.go+++ b/backend/migrator/migrator.go@@ -77,8 +77,6 @@ func MigrateSchema(ctx context.Context, storeDB *store.DB, strictUseDb bool, pgBreturn nil, err}storeInstance := store.New(storeDB)- // TODO(d): backfill migration history.-// Calculate prod cutoffSchemaVersion.cutoffSchemaVersion, err := getProdCutoffVersion()if err != nil {@@ -91,7 +89,8 @@ func MigrateSchema(ctx context.Context, storeDB *store.DB, strictUseDb bool, pgBbytebaseConnConfig := storeDB.ConnCfgif !strictUseDb {- bytebaseConnConfig.Database = dbdriver.BytebaseDatabase+ // BytebaseDatabase was the database installed in the controlled database server.+ bytebaseConnConfig.Database = "bytebase"}bytebaseDriver, err := dbdriver.Open(ctx,diff --git a/backend/plugin/db/driver.go b/backend/plugin/db/driver.goindex c7c89a8125..257b25deac 100644--- a/backend/plugin/db/driver.go+++ b/backend/plugin/db/driver.go@@ -52,9 +52,6 @@ const (// UnknownType is the database type for UNKNOWN.UnknownType Type = "UNKNOWN"- // BytebaseDatabase is the database installed in the controlled database server.- BytebaseDatabase = "bytebase"-// SlowQueryMaxLen is the max length of slow query.SlowQueryMaxLen = 2048// SlowQueryMaxSamplePerFingerprint is the max number of slow query samples per fingerprint.diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.goindex b0adedcbd8..1d6e8eaa02 100644--- a/backend/plugin/db/spanner/spanner.go+++ b/backend/plugin/db/spanner/spanner.go@@ -11,18 +11,14 @@ import (spanner "cloud.google.com/go/spanner"spannerdb "cloud.google.com/go/spanner/admin/database/apiv1""cloud.google.com/go/spanner/admin/database/apiv1/databasepb"- "go.uber.org/zap"sppb "cloud.google.com/go/spanner/apiv1/spannerpb""github.com/pkg/errors"- "github.com/bytebase/bytebase/backend/common/log""github.com/bytebase/bytebase/backend/plugin/db""google.golang.org/api/iterator""google.golang.org/api/option"- "google.golang.org/grpc/codes"- "google.golang.org/grpc/status")var (@@ -55,27 +51,14 @@ func newDriver(_ db.DriverConfig) db.Driver {}// Open opens a Spanner driver. It must connect to a specific database.-// If database isn't provided, the driver tries to connect to "bytebase" database.-// If connecting to "bytebase" also fails, part of the driver cannot function.+// If database isn't provided, part of the driver cannot function.func (d *Driver) Open(ctx context.Context, _ db.Type, config db.ConnectionConfig, connCtx db.ConnectionContext) (db.Driver, error) {if config.Host == "" {return nil, errors.New("host cannot be empty")}d.config = configd.connCtx = connCtx- if config.Database == "" {- // try to connect to bytebase- d.databaseName = db.BytebaseDatabase- dsn := getDSN(d.config.Host, db.BytebaseDatabase)- client, err := spanner.NewClient(ctx, dsn, option.WithCredentialsJSON([]byte(config.Password)))- if status.Code(err) == codes.NotFound {- log.Debug(`spanner driver: no database provided, try connecting to "bytebase" database which is not found`, zap.Error(err))- } else if err != nil {- return nil, err- } else {- d.client = client- }- } else {+ if config.Database != "" {d.databaseName = d.config.Databasedsn := getDSN(d.config.Host, d.config.Database)client, err := spanner.NewClient(ctx, dsn, option.WithCredentialsJSON([]byte(config.Password)))diff --git a/backend/runner/taskrun/pitr_cutover_executor.go b/backend/runner/taskrun/pitr_cutover_executor.goindex 2e868feb00..30d8935875 100644--- a/backend/runner/taskrun/pitr_cutover_executor.go+++ b/backend/runner/taskrun/pitr_cutover_executor.go@@ -239,7 +239,7 @@ func (exec *PITRCutoverExecutor) pitrCutoverPostgres(ctx context.Context, instanpitrDatabaseName := util.GetPITRDatabaseName(databaseName, issue.CreatedTime.Unix())pitrOldDatabaseName := util.GetPITROldDatabaseName(databaseName, issue.CreatedTime.Unix())- defaultDBDriver, err := exec.dbFactory.GetAdminDatabaseDriver(ctx, instance, db.BytebaseDatabase)+ defaultDBDriver, err := exec.dbFactory.GetAdminDatabaseDriver(ctx, instance, "")if err != nil {return err}