Skip to content

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

refactor: remove deprecated --pg flag (#17129)

Danny Xuee3e5829d2fd
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.go
index 0ced424936..898d320a11 100644
--- a/backend/bin/server/cmd/profile.go
+++ b/backend/bin/server/cmd/profile.go
@@ -29,7 +29,7 @@ func getBaseProfile(dataDir string) *config.Profile {
Demo: flags.demo,
Version: version,
GitCommit: gitcommit,
- PgURL: flags.pgURL,
+ PgURL: os.Getenv("PG_URL"),
DeployID: uuid.NewString()[:8],
}
diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.go
index b46db94316..edcf177d01 100644
--- a/backend/bin/server/cmd/root.go
+++ b/backend/bin/server/cmd/root.go
@@ -61,12 +61,9 @@ var (
// Used for Bytebase command line config
port int
externalURL string
- // pgURL must follow PostgreSQL connection URIs pattern.
- // https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
- pgURL string
- dataDir string
- ha bool
- saas bool
+ dataDir string
+ ha bool
+ saas bool
// output logs in json format
enableJSONLogging bool
// demo mode.
@@ -104,11 +101,7 @@ func init() {
// Instead they would configure a gateway to forward the traffic to Bytebase. Users need to set --external-url to the address
// exposed on that gateway accordingly.
rootCmd.PersistentFlags().StringVar(&flags.externalURL, "external-url", "", "the external URL where user visits Bytebase, must start with http:// or https://")
- // Support environment variable for deploying to render.com using its blueprint file.
- // Render blueprint allows to specify a postgres database along with a service.
- // It allows to pass the postgres connection string as an ENV to the service.
- rootCmd.PersistentFlags().StringVar(&flags.pgURL, "pg", os.Getenv("PG_URL"), "optional external PostgreSQL instance connection url (must provide dbname); for example postgresql://user:secret@masterhost:5432/dbname?sslrootcert=cert")
- rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", ".", "not recommended for production. Directory where Bytebase stores data if --pg is not specified. If relative path is supplied, then the path is relative to the directory where Bytebase is under")
+ rootCmd.PersistentFlags().StringVar(&flags.dataDir, "data", ".", "not recommended for production. Directory where Bytebase stores data if PG_URL is not specified. If relative path is supplied, then the path is relative to the directory where Bytebase is under")
rootCmd.PersistentFlags().BoolVar(&flags.ha, "ha", false, "run in HA mode")
rootCmd.PersistentFlags().BoolVar(&flags.saas, "saas", false, "run in SaaS mode")
rootCmd.PersistentFlags().BoolVar(&flags.enableJSONLogging, "enable-json-logging", false, "enable output logs in bytebase in json format")
@@ -176,16 +169,16 @@ func start() {
return
}
+ profile := activeProfile(flags.dataDir)
+
// A safety measure to prevent accidentally resetting user's actual data with demo data.
// For emebeded mode, we control where data is stored and we put demo data in a separate directory
// from the non-demo data.
- if flags.demo && flags.pgURL != "" {
+ if flags.demo && profile.PgURL != "" {
slog.Error("demo mode is disallowed when storing metadata in external PostgreSQL instance")
return
}
- profile := activeProfile(flags.dataDir)
-
// The ideal bootstrap order is:
// 1. Connect to the metadb
// 2. Start echo server