You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/09/20 13:42:44 UTC

[GitHub] [incubator-devlake] klesh commented on a diff in pull request #3135: fix: fix migrator bug

klesh commented on code in PR #3135:
URL: https://github.com/apache/incubator-devlake/pull/3135#discussion_r975382348


##########
models/migrationscripts/20220913_commitfile_add_length.go:
##########
@@ -68,11 +68,28 @@ func (CommitFileComponentBak) TableName() string {
 type addCommitFilePathLength struct{}
 
 func (*addCommitFilePathLength) Up(ctx context.Context, db *gorm.DB) errors.Error {
-	err := db.Migrator().RenameTable(&CommitFile{}, &CommitFileAddLengthBak{})
-	if err != nil {
-		return errors.Default.Wrap(err, "error no rename commit_file to commit_files_bak")
+	var err error
+
+	// commit_files
+	// rename the commit_file_bak to cache old table
+	if db.Migrator().HasTable(&CommitFileAddLengthBak{}) {

Review Comment:
   What if the user wants to go back to the old version when upgrade failed?
   I suggest we use a `defer` function, revert to the original state if there was any err, or delete the backup table otherwise



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org