Update database configuration to support custom SQLite path
This commit is contained in:
parent
e862a281d9
commit
2d538ff43c
|
@ -2,6 +2,7 @@ package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
|
@ -33,7 +34,12 @@ func NewDatabase(cfg *config.Config) (*gorm.DB, error) {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
|
path := os.Getenv("DT_SQLITE_PATH")
|
||||||
|
if path == "" {
|
||||||
db, err = gorm.Open(sqlite.Open("donetick.db"), &gorm.Config{})
|
db, err = gorm.Open(sqlite.Open("donetick.db"), &gorm.Config{})
|
||||||
|
} else {
|
||||||
|
db, err = gorm.Open(sqlite.Open(path), &gorm.Config{})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue