forked from forgejo/forgejo
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
This commit is contained in:
parent
bfdfa9a8b3
commit
f6067a8465
18 changed files with 567 additions and 32 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue