Merge pull request #789 from statping/dev

quick fix for migration version number
pull/792/head
Hunter Long 2020-08-17 19:48:08 -07:00 committed by GitHub
commit b002847b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

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

View File

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