add database reset flag
This commit is contained in:
parent
bf34abf5f8
commit
3aeda54404
2 changed files with 18 additions and 7 deletions
|
@ -33,7 +33,7 @@ func sub(a, b int) int {
|
|||
|
||||
var db *pgxpool.Pool
|
||||
|
||||
func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS embed.FS) {
|
||||
func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS embed.FS, resetDB bool) {
|
||||
conf = _conf
|
||||
|
||||
// Static Files
|
||||
|
@ -70,6 +70,15 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
|
|||
return
|
||||
}
|
||||
|
||||
if resetDB {
|
||||
slog.Info("Running Down Migrations...")
|
||||
err = m.Down()
|
||||
if err != nil {
|
||||
slog.Error("Unable to Migrate Down", "err", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//err = m.Down()
|
||||
err = m.Up()
|
||||
if err == migrate.ErrNoChange {
|
||||
|
@ -95,10 +104,10 @@ func Start(_conf config.Config, tmplFS embed.FS, staticFS embed.FS, migrationsFS
|
|||
server := &http.Server{
|
||||
Addr: conf.Server.Address,
|
||||
Handler: mux,
|
||||
ReadTimeout: 1 * time.Second,
|
||||
WriteTimeout: 1 * time.Second,
|
||||
ReadTimeout: 10 * time.Second,
|
||||
WriteTimeout: 10 * time.Second,
|
||||
IdleTimeout: 30 * time.Second,
|
||||
ReadHeaderTimeout: 2 * time.Second,
|
||||
ReadHeaderTimeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
serverClose := make(chan bool)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue