diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-24 01:28:15 +0800 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2020-01-23 19:28:15 +0200 |
commit | f6067a8465e7762aea1561106cfee291409a0fd6 (patch) | |
tree | 35c97d4117acfe52dce32c9242e4c9a656c4bc6c /models/migrate.go | |
parent | bfdfa9a8b32ae331f98137169693ba1d71c25b09 (diff) | |
download | gitea-f6067a8465e7762aea1561106cfee291409a0fd6.tar.gz gitea-f6067a8465e7762aea1561106cfee291409a0fd6.zip |
Migrate reviews when migrating repository from github (#9463)
* fix typo
* Migrate reviews when migrating repository from github
* fix lint
* Added test and migration when external user login
* fix test
* fix commented state
* Some improvements
* fix bug when get pull request and ref original author on code comments
* Fix migrated line; Added comment for review
* Don't load all pull requests attributes
* Fix typo
* wrong change copy head
* fix tests
* fix reactions
* Fix test
* fix fmt
* fix review comment reactions
Diffstat (limited to 'models/migrate.go')
-rw-r--r-- | models/migrate.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/models/migrate.go b/models/migrate.go index fd28fd156f..28661527a6 100644 --- a/models/migrate.go +++ b/models/migrate.go @@ -4,7 +4,12 @@ package models -import "xorm.io/xorm" +import ( + "code.gitea.io/gitea/modules/structs" + + "xorm.io/builder" + "xorm.io/xorm" +) // InsertMilestones creates milestones of repository. func InsertMilestones(ms ...*Milestone) (err error) { @@ -202,3 +207,23 @@ func InsertReleases(rels ...*Release) error { return sess.Commit() } + +// 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). + Update(map[string]interface{}{ + "poster_id": posterID, + "original_author": "", + "original_author_id": 0, + }) + return err +} |