the env will now let you define if the migrations should run on startup

This commit is contained in:
James Tombleson 2024-04-05 17:49:30 -07:00
parent 0c7c4d311e
commit d2aa1b99ce
2 changed files with 15 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package domain
type EnvConfig struct {
AdminToken string
JwtSecret string
}
AdminToken string
JwtSecret string
DisableMigrationsOnStartUp bool
}

View File

@ -1,9 +1,11 @@
package services
import (
"go-cook/api/domain"
"log"
"os"
"strconv"
"git.jamestombleson.com/jtom38/go-cook/api/domain"
"github.com/joho/godotenv"
)
@ -14,8 +16,14 @@ func NewEnvConfig() domain.EnvConfig {
log.Println(err)
}
disableMigrations, err := strconv.ParseBool(os.Getenv("DisableMigrationsOnStartup"))
if err != nil {
disableMigrations = false
}
return domain.EnvConfig{
AdminToken: os.Getenv("AdminToken"),
JwtSecret: os.Getenv("JwtSecret"),
AdminToken: os.Getenv("AdminToken"),
JwtSecret: os.Getenv("JwtSecret"),
DisableMigrationsOnStartUp: disableMigrations,
}
}