File tree Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Expand file tree Collapse file tree 4 files changed +20
-23
lines changed Original file line number Diff line number Diff line change @@ -10,21 +10,15 @@ import (
10
10
"github.com/go-xorm/xorm"
11
11
)
12
12
13
- // UserV15 describes the added field for User
14
- type UserV15 struct {
15
- KeepEmailPrivate bool
16
- AllowCreateOrganization bool
17
- }
18
-
19
- // TableName will be invoked by XORM to customrize the table name
20
- func (* UserV15 ) TableName () string {
21
- return "user"
22
- }
23
-
24
13
func createAllowCreateOrganizationColumn (x * xorm.Engine ) error {
25
- if err := x .Sync2 (new (UserV15 )); err != nil {
14
+ type User struct {
15
+ KeepEmailPrivate bool
16
+ AllowCreateOrganization bool
17
+ }
18
+
19
+ if err := x .Sync2 (new (User )); err != nil {
26
20
return fmt .Errorf ("Sync2: %v" , err )
27
- } else if _ , err = x .Where ("type= 0" ).Cols ("allow_create_organization" ).Update (& UserV15 {AllowCreateOrganization : true }); err != nil {
21
+ } else if _ , err = x .Where ("` type` = 0" ).Cols ("allow_create_organization" ).Update (& User {AllowCreateOrganization : true }); err != nil {
28
22
return fmt .Errorf ("set allow_create_organization: %v" , err )
29
23
}
30
24
return nil
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ func addUnitsToTables(x *xorm.Engine) error {
33
33
RepoID int64 `xorm:"INDEX(s)"`
34
34
Type int `xorm:"INDEX(s)"`
35
35
Index int
36
- Config map [string ]string `xorm:"JSON"`
37
- CreatedUnix int64 `xorm:"INDEX CREATED"`
38
- Created time.Time `xorm:"-"`
36
+ Config map [string ]interface {} `xorm:"JSON"`
37
+ CreatedUnix int64 `xorm:"INDEX CREATED"`
38
+ Created time.Time `xorm:"-"`
39
39
}
40
40
41
41
// Repo describes a repository
@@ -95,7 +95,7 @@ func addUnitsToTables(x *xorm.Engine) error {
95
95
continue
96
96
}
97
97
98
- var config = make (map [string ]string )
98
+ var config = make (map [string ]interface {} )
99
99
switch i {
100
100
case V16UnitTypeExternalTracker :
101
101
config ["ExternalTrackerURL" ] = repo .ExternalTrackerURL
Original file line number Diff line number Diff line change @@ -7,24 +7,27 @@ package migrations
7
7
import (
8
8
"html"
9
9
10
- "code.gitea.io/gitea/models"
11
-
12
10
"github.com/go-xorm/xorm"
13
11
)
14
12
15
13
func unescapeUserFullNames (x * xorm.Engine ) (err error ) {
14
+ type User struct {
15
+ ID int64 `xorm:"pk autoincr"`
16
+ FullName string
17
+ }
18
+
16
19
const batchSize = 100
17
20
for start := 0 ; ; start += batchSize {
18
- users := make ([]* models. User , 0 , batchSize )
19
- if err := x .Limit (start , batchSize ).Find (users ); err != nil {
21
+ users := make ([]* User , 0 , batchSize )
22
+ if err := x .Limit (batchSize , start ).Find (& users ); err != nil {
20
23
return err
21
24
}
22
25
if len (users ) == 0 {
23
26
return nil
24
27
}
25
28
for _ , user := range users {
26
29
user .FullName = html .UnescapeString (user .FullName )
27
- if _ , err := x .Cols ("full_name" ).Update (user ); err != nil {
30
+ if _ , err := x .ID ( user . ID ). Cols ("full_name" ).Update (user ); err != nil {
28
31
return err
29
32
}
30
33
}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ func removeCommitsUnitType(x *xorm.Engine) (err error) {
47
47
}
48
48
}
49
49
team .UnitTypes = ut
50
- if _ , err := x .Id (team .ID ).Cols ("unit_types" ).Update (team ); err != nil {
50
+ if _ , err := x .ID (team .ID ).Cols ("unit_types" ).Update (team ); err != nil {
51
51
return err
52
52
}
53
53
}
You can’t perform that action at this time.
0 commit comments