warren830 commented on code in PR #2950:
URL: https://github.com/apache/incubator-devlake/pull/2950#discussion_r962560011


##########
plugins/jira/models/migrationscripts/20220716_add_init_tables.go:
##########
@@ -99,8 +117,15 @@ func (*addInitTables) Up(ctx context.Context, db *gorm.DB) 
error {
        }
        defer db.Migrator().DropTable(&JiraConnectionTemp{})
 
+       // cached plan must not change result type in postgres, so need to 
update db name
+       err = db.Migrator().RenameTable(JiraConnectionV011{}, 
JiraConnectionV011Bak{})
+       if err != nil {
+               return err
+       }
+       defer db.Migrator().DropTable(&JiraConnectionV011Bak{})
+
        var result *gorm.DB
-       var jiraConns []JiraConnectionV011
+       var jiraConns []JiraConnectionV011Bak
        result = db.Find(&jiraConns)
 
        if result.Error == nil {

Review Comment:
   Also, please do not use if like this, you can simply use `if result.Error != 
nil` and return err. Code like this make it difficult to understand



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to