mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-19 19:30:28 +05:00
Add the ability to set the path to the database
This commit is contained in:
parent
8c32cb1071
commit
c21b20f356
|
@ -3,10 +3,16 @@ package backend
|
|||
import (
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetDatabaseConnection() (*gorm.DB, error) {
|
||||
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
|
||||
dbPath := os.Getenv("PHOENIX_DB_PATH")
|
||||
if dbPath == "" {
|
||||
dbPath = "db.sqlite3"
|
||||
}
|
||||
|
||||
db, err := gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue