diff --git a/common/keydb/keydb.go b/common/keydb/keydb.go index b9fa884e2..04692e98c 100644 --- a/common/keydb/keydb.go +++ b/common/keydb/keydb.go @@ -33,7 +33,9 @@ type Database interface { func NewDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewDatabase(dataSourceName) } switch uri.Scheme { case "postgres": diff --git a/federationsender/storage/storage.go b/federationsender/storage/storage.go index 8cffdbf1a..9f2805cf7 100644 --- a/federationsender/storage/storage.go +++ b/federationsender/storage/storage.go @@ -34,12 +34,14 @@ type Database interface { func NewDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewDatabase(dataSourceName) } switch uri.Scheme { case "postgres": return postgres.NewDatabase(dataSourceName) default: - return nil, errors.New("unknown schema") + return errors.New("unknown schema") } } diff --git a/mediaapi/storage/storage.go b/mediaapi/storage/storage.go index 0f39c1d0c..ca9f69f8f 100644 --- a/mediaapi/storage/storage.go +++ b/mediaapi/storage/storage.go @@ -36,7 +36,9 @@ type Database interface { func Open(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.Open(dataSourceName) } switch uri.Scheme { case "postgres": diff --git a/publicroomsapi/storage/storage.go b/publicroomsapi/storage/storage.go index a6a39d523..d611686ba 100644 --- a/publicroomsapi/storage/storage.go +++ b/publicroomsapi/storage/storage.go @@ -39,7 +39,9 @@ type Database interface { func NewPublicRoomsServerDatabase(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewPublicRoomsServerDatabase(dataSourceName) } switch uri.Scheme { case "postgres": diff --git a/roomserver/storage/storage.go b/roomserver/storage/storage.go index 325d96e99..62e8b64c3 100644 --- a/roomserver/storage/storage.go +++ b/roomserver/storage/storage.go @@ -61,7 +61,9 @@ type Database interface { func Open(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.Open(dataSourceName) } switch uri.Scheme { case "postgres": diff --git a/syncapi/storage/storage.go b/syncapi/storage/storage.go index eedb42f0e..4d896531a 100644 --- a/syncapi/storage/storage.go +++ b/syncapi/storage/storage.go @@ -52,7 +52,9 @@ type Database interface { func NewSyncServerDatasource(dataSourceName string) (Database, error) { uri, err := url.Parse(dataSourceName) if err != nil { - return nil, err + // if the scheme doesn't match, fall back to postgres in case the config has + // postgres key=value connection strings + return postgres.NewSyncServerDatasource(dataSourceName) } switch uri.Scheme { case "postgres":