aboutsummaryrefslogtreecommitdiffstats
path: root/models/migrate.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-02-18 08:42:13 +0800
committerGitHub <noreply@github.com>2020-02-17 19:42:13 -0500
commitce0413ff8894660f0a5f0a87cbadb6baacb80e4a (patch)
tree6608e4b26f200eba0dc4f6ca3489e791ff9baccd /models/migrate.go
parente76a64dda173db84e34eefc6baaa2981fe4a6801 (diff)
downloadgitea-ce0413ff8894660f0a5f0a87cbadb6baacb80e4a.tar.gz
gitea-ce0413ff8894660f0a5f0a87cbadb6baacb80e4a.zip
Fix migration information update bug when linked github account (#10310)
* Fix bug on upgrade migrated reactions * Fix migration information update bug when linked github account Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'models/migrate.go')
-rw-r--r--models/migrate.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/models/migrate.go b/models/migrate.go
index 28661527a6..ea4a8c1768 100644
--- a/models/migrate.go
+++ b/models/migrate.go
@@ -208,20 +208,24 @@ func InsertReleases(rels ...*Release) error {
return sess.Commit()
}
+func migratedIssueCond(tp structs.GitServiceType) builder.Cond {
+ return builder.In("issue_id",
+ builder.Select("issue.id").
+ From("issue").
+ InnerJoin("repository", "issue.repo_id = repository.id").
+ Where(builder.Eq{
+ "repository.original_service_type": tp,
+ }),
+ )
+}
+
// UpdateReviewsMigrationsByType updates reviews' migrations information via given git service type and original id and poster id
func UpdateReviewsMigrationsByType(tp structs.GitServiceType, originalAuthorID string, posterID int64) error {
_, err := x.Table("review").
- Where(builder.In("issue_id",
- builder.Select("issue.id").
- From("issue").
- InnerJoin("repository", "issue.repo_id = repository.id").
- Where(builder.Eq{
- "repository.original_service_type": tp,
- }),
- )).
- And("review.original_author_id = ?", originalAuthorID).
+ Where("original_author_id = ?", originalAuthorID).
+ And(migratedIssueCond(tp)).
Update(map[string]interface{}{
- "poster_id": posterID,
+ "reviewer_id": posterID,
"original_author": "",
"original_author_id": 0,
})