Add the ability to set the path to the database

This commit is contained in:
Ivan R. 2023-04-09 12:05:50 +05:00
parent 8c32cb1071
commit c21b20f356
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
2 changed files with 11 additions and 1 deletions

View file

@ -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
}

View file

@ -5,3 +5,7 @@ Self-hosted start page without the extra stuff.
## Features
- No javascript
- Tiny footprint
## Configuration
Service settings can be set through environment variables.
- `PHOENIX_DB_PATH` - path to the sqlite database.