aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-06-09 22:34:05 +0200
committerGitHub <noreply@github.com>2020-06-09 16:34:05 -0400
commit363e51d19c7ae63a12554fbfb4dd4f59e87db339 (patch)
tree9a4268f55796fe07c387d7169925a5de46180a02 /models
parentaaff47ad75e167838a886126ddba0ad8f6f1d073 (diff)
downloadgitea-363e51d19c7ae63a12554fbfb4dd4f59e87db339.tar.gz
gitea-363e51d19c7ae63a12554fbfb4dd4f59e87db339.zip
Refactor: Remove Dependencys from Migration v112-v119 (#11811)
* v119 * v116 * v112
Diffstat (limited to 'models')
-rw-r--r--models/migrations/v112.go10
-rw-r--r--models/migrations/v116.go10
-rw-r--r--models/migrations/v119.go6
3 files changed, 18 insertions, 8 deletions
diff --git a/models/migrations/v112.go b/models/migrations/v112.go
index 2c4f659675..76d9933689 100644
--- a/models/migrations/v112.go
+++ b/models/migrations/v112.go
@@ -5,9 +5,12 @@
package migrations
import (
+ "fmt"
"os"
+ "path"
+
+ "code.gitea.io/gitea/modules/setting"
- "code.gitea.io/gitea/models"
"xorm.io/builder"
"xorm.io/xorm"
)
@@ -27,7 +30,10 @@ func removeAttachmentMissedRepo(x *xorm.Engine) error {
}
for i := 0; i < len(attachments); i++ {
- os.RemoveAll(models.AttachmentLocalPath(attachments[i].UUID))
+ uuid := attachments[i].UUID
+ if err = os.RemoveAll(path.Join(setting.AttachmentPath, uuid[0:1], uuid[1:2], uuid)); err != nil {
+ fmt.Printf("Error: %v", err)
+ }
}
if len(attachments) < 50 {
diff --git a/models/migrations/v116.go b/models/migrations/v116.go
index 6587d02f13..254d4e7a19 100644
--- a/models/migrations/v116.go
+++ b/models/migrations/v116.go
@@ -5,12 +5,16 @@
package migrations
import (
- "code.gitea.io/gitea/models"
-
"xorm.io/xorm"
)
func extendTrackedTimes(x *xorm.Engine) error {
+
+ type TrackedTime struct {
+ Time int64 `xorm:"NOT NULL"`
+ Deleted bool `xorm:"NOT NULL DEFAULT false"`
+ }
+
sess := x.NewSession()
defer sess.Close()
@@ -22,7 +26,7 @@ func extendTrackedTimes(x *xorm.Engine) error {
return err
}
- if err := sess.Sync2(new(models.TrackedTime)); err != nil {
+ if err := sess.Sync2(new(TrackedTime)); err != nil {
return err
}
diff --git a/models/migrations/v119.go b/models/migrations/v119.go
index 746a04ead4..9622ff587c 100644
--- a/models/migrations/v119.go
+++ b/models/migrations/v119.go
@@ -5,12 +5,12 @@
package migrations
import (
- "code.gitea.io/gitea/modules/structs"
-
"xorm.io/xorm"
)
func fixMigratedRepositoryServiceType(x *xorm.Engine) error {
- _, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", structs.GithubService)
+ // structs.GithubService:
+ // GithubService = 2
+ _, err := x.Exec("UPDATE repository SET original_service_type = ? WHERE original_url LIKE 'https://github.com/%'", 2)
return err
}