Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: disable --pg for now as it requires more bake time (#1062)
tianzhou7c01ff7e22db
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.goindex 047374cdb4..4ec412d14d 100644--- a/bin/server/cmd/root.go+++ b/bin/server/cmd/root.go@@ -129,7 +129,10 @@ func init() {rootCmd.PersistentFlags().BoolVar(&readonly, "readonly", false, "whether to run in read-only mode")rootCmd.PersistentFlags().BoolVar(&demo, "demo", false, "whether to run using demo data")rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "whether to enable debug level logging")- rootCmd.PersistentFlags().StringVar(&pgURL, "pg", "", "optional external PostgreSQL instance connection url; for example postgresql://user:secret@masterhost:5433/dbname?sslrootcert=cert")+ // TODO(tianzhou): this needs more bake time. There are couple blocking issues:+ // 1. Currently, we will create a separate bytebase database to store the migration_history table, we need to put it inside the specified database here.+ // 2. We need to move the logic of creating bytebase metadata db logic outside. Because with --pg option, the db has already been created.+ // rootCmd.PersistentFlags().StringVar(&pgURL, "pg", "", "optional external PostgreSQL instance connection url; for example postgresql://user:secret@masterhost:5432/dbname?sslrootcert=cert")}// -----------------------------------Command Line Config END--------------------------------------@@ -293,6 +296,8 @@ func NewMain(activeProfile Profile, logger *zap.Logger) (*Main, error) {if useEmbeddedDB() {logger.Info("Preparing embedded PostgreSQL instance...")var err error+ // Installs the Postgres binary and creates the 'activeProfile.pgUser' user/database+ // to store Bytebase's own metadata.pgInstance, err = postgres.Install(resourceDir, pgDataDir, activeProfile.pgUser)if err != nil {return nil, err@@ -369,6 +374,10 @@ func (m *Main) newExternalDB() (*store.DB, error) {connCfg.Password, _ = u.User.Password()}+ if connCfg.Username == "" {+ return nil, fmt.Errorf("missing user in the --pg connection string")+ }+if host, port, err := net.SplitHostPort(u.Host); err != nil {connCfg.Host = u.Host} else {@@ -376,6 +385,8 @@ func (m *Main) newExternalDB() (*store.DB, error) {connCfg.Port = port}+ // By default, follow the PG convention to use user name as the database name+ connCfg.Database = connCfg.Usernameif u.Path != "" {connCfg.Database = u.Path[1:]}diff --git a/store/pg_engine.go b/store/pg_engine.goindex e8e52c6f5c..3fac5064fc 100644--- a/store/pg_engine.go+++ b/store/pg_engine.go@@ -117,6 +117,9 @@ func (db *DB) Open(ctx context.Context) (err error) {return nil}+ // We are also using our own migration core to manage our own schema's migration history.+ // So here we will create a "bytebase" database to store the migration history if the target+ // db instance does not have one yet.if err := d.SetupMigrationIfNeeded(ctx); err != nil {return err}