Skip to content

Commit

Permalink
make postgres connection string optional (#948)
Browse files Browse the repository at this point in the history
* make postgres connection string optional

* CR fix: simplify!

* fix import

* CR fix: use temp var
  • Loading branch information
johnnyaug committed Nov 23, 2020
1 parent 24974e3 commit b69c89a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 0 additions & 4 deletions config/config.go
Expand Up @@ -22,8 +22,6 @@ import (
)

const (
DefaultDatabaseConnString = "postgres://localhost:5432/postgres?sslmode=disable"

DefaultBlockStoreType = "local"
DefaultBlockStoreLocalPath = "~/lakefs/data"
DefaultBlockStoreS3Region = "us-east-1"
Expand Down Expand Up @@ -78,8 +76,6 @@ func setDefaults() {
viper.SetDefault("logging.level", DefaultLoggingLevel)
viper.SetDefault("logging.output", DefaultLoggingOutput)

viper.SetDefault("database.connection_string", DefaultDatabaseConnString)

viper.SetDefault("auth.cache.enabled", DefaultAuthCacheEnabled)
viper.SetDefault("auth.cache.size", DefaultAuthCacheSize)
viper.SetDefault("auth.cache.ttl", DefaultAuthCacheTTL)
Expand Down
11 changes: 6 additions & 5 deletions db/migration.go
Expand Up @@ -7,11 +7,9 @@ import (
"os"
"time"

"github.com/golang-migrate/migrate/v4/source"

"github.com/golang-migrate/migrate/v4"

_ "github.com/golang-migrate/migrate/v4/database/postgres"
"github.com/golang-migrate/migrate/v4/source"
"github.com/golang-migrate/migrate/v4/source/httpfs"
"github.com/rakyll/statik/fs"
"github.com/treeverse/lakefs/db/params"
Expand Down Expand Up @@ -107,8 +105,11 @@ func getMigrate(params params.Database) (*migrate.Migrate, error) {
defer func() {
_ = src.Close()
}()

m, err := migrate.NewWithSourceInstance("httpfs", src, params.ConnectionString)
connectionString := params.ConnectionString
if connectionString == "" {
connectionString = "postgres://:/"
}
m, err := migrate.NewWithSourceInstance("httpfs", src, connectionString)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b69c89a

Please sign in to comment.