Refactor: Remove Dependencys from Migration v112-v119 (#11811)

* v119

* v116

* v112
release/v1.15
6543 2020-06-09 22:34:05 +02:00 committed by GitHub
parent aaff47ad75
commit 363e51d19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 8 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}