feat: Added migration tool

This commit is contained in:
2025-08-11 18:58:52 +03:00
parent e5aadbe9c8
commit 40a313f93b
6 changed files with 100 additions and 17 deletions

View File

@@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"git.ostiwe.com/ostiwe-com/status/model"
"git.ostiwe.com/ostiwe-com/status/modules/db"
appLog "git.ostiwe.com/ostiwe-com/status/modules/log"
"git.ostiwe.com/ostiwe-com/status/modules/queue"
@@ -21,11 +20,6 @@ func Run(serverArgs *args.ServerCmd) {
}
db.SetGlobal(connect)
appLog.Global.Get(appLog.SYSTEM).Info("Run db migration")
if err = runMigrate(); err != nil {
appLog.Global.Get(appLog.SYSTEM).Error(fmt.Sprintf("Migration failed, error: %v", err))
return
}
appLog.Global.Get(appLog.SYSTEM).Info("Start service observer")
go queue.InitQueues()
@@ -38,10 +32,3 @@ func Run(serverArgs *args.ServerCmd) {
appLog.Global.Get(appLog.SERVER).Error(fmt.Sprintf("Startup server error: %v", err))
}
}
func runMigrate() error {
return db.Global.AutoMigrate(
model.Service{},
model.Status{},
)
}