This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 3274ad0df fix and refactor: db migration logging logic (#7188)
3274ad0df is described below
commit 3274ad0dfdc2af30a13a8cc5c3ceb47072975d8e
Author: Klesh Wong <[email protected]>
AuthorDate: Mon Mar 18 17:08:24 2024 +0800
fix and refactor: db migration logging logic (#7188)
* refactor: db migration logging logic
* fix: linting
---
backend/server/services/init.go | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/backend/server/services/init.go b/backend/server/services/init.go
index b40d99ff2..d332c181a 100644
--- a/backend/server/services/init.go
+++ b/backend/server/services/init.go
@@ -82,13 +82,8 @@ func Init() {
// lock the database to avoid multiple devlake instances from sharing
the same one
lockDatabase()
- var err error
// now, load the plugins
- err = runner.LoadPlugins(basicRes)
- if err != nil {
- logger.Error(err, "failed to load plugins")
- panic(err)
- }
+ errors.Must(runner.LoadPlugins(basicRes))
// pull migration scripts from plugins to migrator
for _, pluginInst := range plugin.AllPlugins() {
@@ -98,14 +93,17 @@ func Init() {
}
// check if there are pending migration
- forceMigration := cfg.GetBool("FORCE_MIGRATION")
- if !migrator.HasPendingScripts() || forceMigration {
- err = ExecuteMigration()
- if err != nil {
- panic(err)
+ if migrator.HasPendingScripts() {
+ if cfg.GetBool("FORCE_MIGRATION") {
+ errors.Must(ExecuteMigration())
+ logger.Info("db migration without confirmation")
+ } else {
+ logger.Info("db migration confirmation needed")
}
+ } else {
+ errors.Must(ExecuteMigration())
+ logger.Info("no db migration needed")
}
- logger.Info("Db migration confirmation needed")
}
// ExecuteMigration executes all pending migration scripts and initialize
services module