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

lynwee pushed a commit to branch debug-1
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit c6b75d62841d6a7f32bed0f7320162ac1bc03379
Author: d4x1 <[email protected]>
AuthorDate: Thu Sep 19 12:50:00 2024 +0800

    fix(migration): panic when `ExecuteMigration` fails
---
 backend/server/api/api.go       | 7 +------
 backend/server/services/init.go | 2 +-
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/backend/server/api/api.go b/backend/server/api/api.go
index 69ca8a374..a2b590be4 100644
--- a/backend/server/api/api.go
+++ b/backend/server/api/api.go
@@ -122,12 +122,7 @@ func SetupApiServer(router *gin.Engine) {
        // Endpoint to proceed database migration
        router.GET("/proceed-db-migration", func(ctx *gin.Context) {
                // Execute database migration
-               err := services.ExecuteMigration()
-               if err != nil {
-                       // Return error response
-                       shared.ApiOutputError(ctx, errors.Default.Wrap(err, 
"error executing migration"))
-                       return
-               }
+               errors.Must(services.ExecuteMigration())
                // Return success response
                shared.ApiOutputSuccess(ctx, nil, http.StatusOK)
        })
diff --git a/backend/server/services/init.go b/backend/server/services/init.go
index 7e794e68a..a4eb334c2 100644
--- a/backend/server/services/init.go
+++ b/backend/server/services/init.go
@@ -96,7 +96,7 @@ func registerPluginsMigrationScripts() {
 
 func InitExecuteMigration() {
        // check if there are pending migration
-       logger.Info("has pending scripts? %v, FORCE_MIGRATION: %s", 
migrator.HasPendingScripts(), cfg.GetBool("FORCE_MIGRATION"))
+       logger.Info("has pending scripts? %v, FORCE_MIGRATION: %v", 
migrator.HasPendingScripts(), cfg.GetBool("FORCE_MIGRATION"))
        if migrator.HasPendingScripts() {
                if cfg.GetBool("FORCE_MIGRATION") {
                        errors.Must(ExecuteMigration())

Reply via email to