Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions serv/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func newDB(
var err error

if cs := conf.DB.ConnString; cs != "" {
if strings.HasPrefix(cs, "postgres://") {
// Check if the connection string has the required prefix or type is set to postgres
if strings.HasPrefix(cs, "postgres://") || strings.HasPrefix(cs, "postgresql://") || conf.DB.Type == "postgres" {
conf.Core.DBType = "postgres"
}
if strings.HasPrefix(cs, "mysql://") {
Expand Down Expand Up @@ -103,17 +104,21 @@ func newDB(
func initPostgres(conf *Config, openDB, useTelemetry bool, fs core.FS) (*dbConf, error) {
confCopy := conf
config, _ := pgx.ParseConfig(confCopy.DB.ConnString)
if confCopy.DB.Host != "" {
config.Host = confCopy.DB.Host
}
if confCopy.DB.Port != 0 {
config.Port = confCopy.DB.Port
}
if confCopy.DB.User != "" {
config.User = confCopy.DB.User
}
if confCopy.DB.Password != "" {
config.Password = confCopy.DB.Password

// Check if the connection string is empty, if it, look at the other fields
if confCopy.DB.ConnString == "" {
if confCopy.DB.Host != "" {
config.Host = confCopy.DB.Host
}
if confCopy.DB.Port != 0 {
config.Port = confCopy.DB.Port
}
if confCopy.DB.User != "" {
config.User = confCopy.DB.User
}
if confCopy.DB.Password != "" {
config.Password = confCopy.DB.Password
}
}

if config.RuntimeParams == nil {
Expand Down
Loading