diff options
Diffstat (limited to 'models/migrations/v37.go')
-rw-r--r-- | models/migrations/v37.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/models/migrations/v37.go b/models/migrations/v37.go index aac00e84cb..00653a780d 100644 --- a/models/migrations/v37.go +++ b/models/migrations/v37.go @@ -7,16 +7,19 @@ package migrations import ( "html" - "code.gitea.io/gitea/models" - "github.com/go-xorm/xorm" ) func unescapeUserFullNames(x *xorm.Engine) (err error) { + type User struct { + ID int64 `xorm:"pk autoincr"` + FullName string + } + const batchSize = 100 for start := 0; ; start += batchSize { - users := make([]*models.User, 0, batchSize) - if err := x.Limit(start, batchSize).Find(users); err != nil { + users := make([]*User, 0, batchSize) + if err := x.Limit(batchSize, start).Find(&users); err != nil { return err } if len(users) == 0 { @@ -24,7 +27,7 @@ func unescapeUserFullNames(x *xorm.Engine) (err error) { } for _, user := range users { user.FullName = html.UnescapeString(user.FullName) - if _, err := x.Cols("full_name").Update(user); err != nil { + if _, err := x.ID(user.ID).Cols("full_name").Update(user); err != nil { return err } } |