From d2aa1b99ce6228fecb239156e620a0617d605fb5 Mon Sep 17 00:00:00 2001 From: James Tombleson Date: Fri, 5 Apr 2024 17:49:30 -0700 Subject: [PATCH] the env will now let you define if the migrations should run on startup --- api/domain/models.go | 7 ++++--- api/services/env.go | 14 +++++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/domain/models.go b/api/domain/models.go index a3028ef..32a0d7b 100644 --- a/api/domain/models.go +++ b/api/domain/models.go @@ -1,6 +1,7 @@ package domain type EnvConfig struct { - AdminToken string - JwtSecret string -} \ No newline at end of file + AdminToken string + JwtSecret string + DisableMigrationsOnStartUp bool +} diff --git a/api/services/env.go b/api/services/env.go index 4b39063..d19ed18 100644 --- a/api/services/env.go +++ b/api/services/env.go @@ -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, } }