diff --git a/cmd/lure-api-server/db.go b/cmd/lure-api-server/db.go index 265a829..22deef4 100644 --- a/cmd/lure-api-server/db.go +++ b/cmd/lure-api-server/db.go @@ -14,15 +14,13 @@ var gdb *sqlx.DB func init() { fi, err := os.Stat(config.DBPath) - if err != nil { - log.Fatal("Cannot stat database path").Err(err).Send() + if err == nil { + // TODO: This should be removed by the first stable release. + if fi.IsDir() { + log.Fatal("Your package cache database is using the old database engine. Please remove ~/.cache/lure and then run `lure ref`.").Send() + } } - - // TODO: This should be removed by the first stable release. - if fi.IsDir() { - log.Fatal("Your package cache database is using the old database engine. Please remove ~/.cache/lure and then run `lure ref`.").Send() - } - + sqlite.MustRegisterScalarFunction("json_array_contains", 2, db.JsonArrayContains) gdb, err = sqlx.Open("sqlite", config.DBPath) diff --git a/db.go b/db.go index 265a829..89a5e63 100644 --- a/db.go +++ b/db.go @@ -14,13 +14,11 @@ var gdb *sqlx.DB func init() { fi, err := os.Stat(config.DBPath) - if err != nil { - log.Fatal("Cannot stat database path").Err(err).Send() - } - - // TODO: This should be removed by the first stable release. - if fi.IsDir() { - log.Fatal("Your package cache database is using the old database engine. Please remove ~/.cache/lure and then run `lure ref`.").Send() + if err == nil { + // TODO: This should be removed by the first stable release. + if fi.IsDir() { + log.Fatal("Your package cache database is using the old database engine. Please remove ~/.cache/lure and then run `lure ref`.").Send() + } } sqlite.MustRegisterScalarFunction("json_array_contains", 2, db.JsonArrayContains)