Init config if needed
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2019-03-28 19:52:58 +01:00
parent 568ad3774a
commit e55af8b20a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,7 @@
package db
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"fmt"
"github.com/go-xorm/core"
@ -29,6 +30,11 @@ import (
// CreateDBEngine initializes a db engine from the config
func CreateDBEngine() (engine *xorm.Engine, err error) {
// If the database type is not set, this likely means we need to initialize the config first
if viper.GetString("database.type") == "" {
config.InitConfig()
}
// Use Mysql if set
if viper.GetString("database.type") == "mysql" {
connStr := fmt.Sprintf(