This is an automated email from the ASF dual-hosted git repository.

abeizn pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit b8cbb4299184ed34dbb545b8e920e889a35cd2eb
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

Reply via email to