Skip to content

Commit 4c9bf91

Browse files
daviianlafriks
authored andcommitted
v38 migration used an outdated version of RepoUnit model (#2602)
* change repoUnit model in migration * fix v16 migration repo_unit table * fix lint error * move type definition inside function Signed-off-by: David Schneiderbauer <[email protected]>
1 parent 03ff768 commit 4c9bf91

File tree

2 files changed

+32
-18
lines changed

2 files changed

+32
-18
lines changed

models/migrations/v16.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ import (
1313
"github.com/go-xorm/xorm"
1414
)
1515

16-
// RepoUnit describes all units of a repository
17-
type RepoUnit struct {
18-
ID int64
19-
RepoID int64 `xorm:"INDEX(s)"`
20-
Type int `xorm:"INDEX(s)"`
21-
Index int
22-
Config map[string]string `xorm:"JSON"`
23-
CreatedUnix int64 `xorm:"INDEX CREATED"`
24-
Created time.Time `xorm:"-"`
25-
}
26-
2716
// Enumerate all the unit types
2817
const (
2918
V16UnitTypeCode = iota + 1 // 1 code
@@ -37,14 +26,25 @@ const (
3726
V16UnitTypeExternalTracker // 9 ExternalTracker
3827
)
3928

40-
// Repo describes a repository
41-
type Repo struct {
42-
ID int64
43-
EnableWiki, EnableExternalWiki, EnableIssues, EnableExternalTracker, EnablePulls bool
44-
ExternalWikiURL, ExternalTrackerURL, ExternalTrackerFormat, ExternalTrackerStyle string
45-
}
46-
4729
func addUnitsToTables(x *xorm.Engine) error {
30+
// RepoUnit describes all units of a repository
31+
type RepoUnit struct {
32+
ID int64
33+
RepoID int64 `xorm:"INDEX(s)"`
34+
Type int `xorm:"INDEX(s)"`
35+
Index int
36+
Config map[string]string `xorm:"JSON"`
37+
CreatedUnix int64 `xorm:"INDEX CREATED"`
38+
Created time.Time `xorm:"-"`
39+
}
40+
41+
// Repo describes a repository
42+
type Repo struct {
43+
ID int64
44+
EnableWiki, EnableExternalWiki, EnableIssues, EnableExternalTracker, EnablePulls bool
45+
ExternalWikiURL, ExternalTrackerURL, ExternalTrackerFormat, ExternalTrackerStyle string
46+
}
47+
4848
var repos []Repo
4949
err := x.Table("repository").Select("*").Find(&repos)
5050
if err != nil {

models/migrations/v38.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@
55
package migrations
66

77
import (
8+
"time"
9+
810
"code.gitea.io/gitea/models"
911

12+
"github.com/go-xorm/core"
1013
"github.com/go-xorm/xorm"
1114
)
1215

1316
func removeCommitsUnitType(x *xorm.Engine) (err error) {
17+
// RepoUnit describes all units of a repository
18+
type RepoUnit struct {
19+
ID int64
20+
RepoID int64 `xorm:"INDEX(s)"`
21+
Type int `xorm:"INDEX(s)"`
22+
Index int
23+
Config core.Conversion `xorm:"TEXT"`
24+
CreatedUnix int64 `xorm:"INDEX CREATED"`
25+
Created time.Time `xorm:"-"`
26+
}
27+
1428
// Update team unit types
1529
const batchSize = 100
1630
for start := 0; ; start += batchSize {

0 commit comments

Comments
 (0)