DB Migrations #67
|
@ -17,6 +17,7 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.vikunja.io/api/pkg/config"
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
|
@ -29,6 +30,11 @@ import (
|
||||||
|
|
||||||
// CreateDBEngine initializes a db engine from the config
|
// CreateDBEngine initializes a db engine from the config
|
||||||
func CreateDBEngine() (engine *xorm.Engine, err error) {
|
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
|
// Use Mysql if set
|
||||||
if viper.GetString("database.type") == "mysql" {
|
if viper.GetString("database.type") == "mysql" {
|
||||||
connStr := fmt.Sprintf(
|
connStr := fmt.Sprintf(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user