Skip to content

Commit 363e51d

Browse files
authored
Refactor: Remove Dependencys from Migration v112-v119 (#11811)
* v119 * v116 * v112
1 parent aaff47a commit 363e51d

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

models/migrations/v112.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
package migrations
66

77
import (
8+
"fmt"
89
"os"
10+
"path"
11+
12+
"code.gitea.io/gitea/modules/setting"
913

10-
"code.gitea.io/gitea/models"
1114
"xorm.io/builder"
1215
"xorm.io/xorm"
1316
)
@@ -27,7 +30,10 @@ func removeAttachmentMissedRepo(x *xorm.Engine) error {
2730
}
2831

2932
for i := 0; i < len(attachments); i++ {
30-
os.RemoveAll(models.AttachmentLocalPath(attachments[i].UUID))
33+
uuid := attachments[i].UUID
34+
if err = os.RemoveAll(path.Join(setting.AttachmentPath, uuid[0:1], uuid[1:2], uuid)); err != nil {
35+
fmt.Printf("Error: %v", err)
36+
}
3137
}
3238

3339
if len(attachments) < 50 {

models/migrations/v116.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
package migrations
66

77
import (
8-
"code.gitea.io/gitea/models"
9-
108
"xorm.io/xorm"
119
)
1210

1311
func extendTrackedTimes(x *xorm.Engine) error {
12+
13+
type TrackedTime struct {
14+
Time int64 `xorm:"NOT NULL"`
15+
Deleted bool `xorm:"NOT NULL DEFAULT false"`
16+
}
17+
1418
sess := x.NewSession()
1519
defer sess.Close()
1620

@@ -22,7 +26,7 @@ func extendTrackedTimes(x *xorm.Engine) error {
2226
return err
2327
}
2428

25-
if err := sess.Sync2(new(models.TrackedTime)); err != nil {
29+
if err := sess.Sync2(new(TrackedTime)); err != nil {
2630
return err
2731
}
2832

models/migrations/v119.go

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

77
import (
8-
"code.gitea.io/gitea/modules/structs"
9-
108
"xorm.io/xorm"
119
)
1210

1311
func fixMigratedRepositoryServiceType(x *xorm.Engine) error {
14-
_, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", structs.GithubService)
12+
// structs.GithubService:
13+
// GithubService = 2
14+
_, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", 2)
1515
return err
1616
}

0 commit comments

Comments
 (0)