feature: Adds production support.

This commit is contained in:
Tera << 8 2024-12-23 22:37:28 -05:00
parent a8bc56ccb5
commit b0b11413fb
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
6 changed files with 46 additions and 3 deletions

View file

@ -4,6 +4,7 @@ import (
"fmt"
"os"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
@ -83,6 +84,14 @@ func InitializeDatabaseDialector() (gorm.Dialector, error) {
}
return sqlite.Open(filePath), nil
case "postgresql":
postgresDSN := os.Getenv("HERMES_POSTGRES_DSN")
if postgresDSN == "" {
return nil, fmt.Errorf("postgres DSN not specified (missing HERMES_POSTGRES_DSN)")
}
return postgres.Open(postgresDSN), nil
case "":
return nil, fmt.Errorf("no database backend specified in environment variables (missing HERMES_DATABASE_BACKEND)")
default: