* v119 * v116 * v112tags/v1.13.0-rc1
package migrations | package migrations | ||||
import ( | import ( | ||||
"fmt" | |||||
"os" | "os" | ||||
"path" | |||||
"code.gitea.io/gitea/modules/setting" | |||||
"code.gitea.io/gitea/models" | |||||
"xorm.io/builder" | "xorm.io/builder" | ||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
} | } | ||||
for i := 0; i < len(attachments); i++ { | 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 { | if len(attachments) < 50 { |
package migrations | package migrations | ||||
import ( | import ( | ||||
"code.gitea.io/gitea/models" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
func extendTrackedTimes(x *xorm.Engine) error { | func extendTrackedTimes(x *xorm.Engine) error { | ||||
type TrackedTime struct { | |||||
Time int64 `xorm:"NOT NULL"` | |||||
Deleted bool `xorm:"NOT NULL DEFAULT false"` | |||||
} | |||||
sess := x.NewSession() | sess := x.NewSession() | ||||
defer sess.Close() | defer sess.Close() | ||||
return err | return err | ||||
} | } | ||||
if err := sess.Sync2(new(models.TrackedTime)); err != nil { | |||||
if err := sess.Sync2(new(TrackedTime)); err != nil { | |||||
return err | return err | ||||
} | } | ||||
package migrations | package migrations | ||||
import ( | import ( | ||||
"code.gitea.io/gitea/modules/structs" | |||||
"xorm.io/xorm" | "xorm.io/xorm" | ||||
) | ) | ||||
func fixMigratedRepositoryServiceType(x *xorm.Engine) error { | 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 | return err | ||||
} | } |