From 8e621fea31491d0a202e0a86d32f933a4f9294c1 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Mon, 17 Aug 2020 19:45:50 -0700 Subject: [PATCH] quick fix for migration version number --- cmd/main.go | 2 ++ types/configs/migration.go | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index de27f2ec..e9f0072c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -31,6 +31,8 @@ func init() { stopped = make(chan bool, 1) core.New(VERSION) utils.InitEnvs() + configs.Version = VERSION + configs.Commit = COMMIT rootCmd.AddCommand(versionCmd) rootCmd.AddCommand(updateCmd) diff --git a/types/configs/migration.go b/types/configs/migration.go index 953e8455..4ab2b445 100644 --- a/types/configs/migration.go +++ b/types/configs/migration.go @@ -21,6 +21,11 @@ import ( "github.com/statping/statping/types/users" ) +var ( + Version string + Commit string +) + func (d *DbConfig) ResetCore() error { if d.Db.HasTable("core") { return nil @@ -121,7 +126,7 @@ func (d *DbConfig) MigrateDatabase() error { } } - log.Infof("Migrating App to version: %s", core.App.Version) + log.Infof("Migrating App to version: %s (%s)", Version, Commit) if err := tx.Table("core").AutoMigrate(&core.Core{}); err.Error() != nil { tx.Rollback() log.Errorln(fmt.Sprintf("Statping Database could not be migrated: %v", tx.Error())) @@ -132,7 +137,7 @@ func (d *DbConfig) MigrateDatabase() error { return err } - d.Db.Table("core").Model(&core.Core{}).Update("version", core.App.Version) + d.Db.Table("core").Model(&core.Core{}).Update("version", Version) log.Infoln("Statping Database Tables Migrated")