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")