Add migrations for wrong negative line number in the review code comment

This commit is contained in:
Lunny Xiao 2025-07-14 15:13:40 -07:00
parent 5ba2216a8c
commit aaa53641ae
2 changed files with 18 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import (
"code.gitea.io/gitea/models/migrations/v1_22"
"code.gitea.io/gitea/models/migrations/v1_23"
"code.gitea.io/gitea/models/migrations/v1_24"
"code.gitea.io/gitea/models/migrations/v1_25"
"code.gitea.io/gitea/models/migrations/v1_6"
"code.gitea.io/gitea/models/migrations/v1_7"
"code.gitea.io/gitea/models/migrations/v1_8"
@ -382,6 +383,9 @@ func prepareMigrationTasks() []*migration {
newMigration(318, "Add anonymous_access_mode for repo_unit", v1_24.AddRepoUnitAnonymousAccessMode),
newMigration(319, "Add ExclusiveOrder to Label table", v1_24.AddExclusiveOrderColumnToLabelTable),
newMigration(320, "Migrate two_factor_policy to login_source table", v1_24.MigrateSkipTwoFactor),
// Gitea 1.24.0 ends at database version 321
newMigration(321, "Migrate commit id of pull requests code review comment", v1_25.MigrateCommitIDOfPullRequestCodeReviewComment),
}
return preparedMigrations
}

View File

@ -0,0 +1,14 @@
// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package v1_25
import (
"xorm.io/xorm"
)
// MigrateCommitIDOfPullRequestCodeReviewComment this will be almost right before comment on the special commit of the pull request
func MigrateCommitIDOfPullRequestCodeReviewComment(x *xorm.Engine) error {
_, err := x.Exec("UPDATE comment SET commit_sha = (select merge_base from pull_request WHERE issue_id = comment.issue_id) WHERE line < 0")
return err
}