Migrations (v82,v96,v99,v136) remove dependencies (#12286)
* remove dependencys * add missing fields * CI.restart()
This commit is contained in:
parent
8e20daaede
commit
2753d72773
4 changed files with 35 additions and 11 deletions
|
@ -11,7 +11,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
@ -29,7 +28,9 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error {
|
|||
}
|
||||
|
||||
type PullRequest struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
IssueID int64 `xorm:"INDEX"`
|
||||
Index int64
|
||||
|
||||
CommitsAhead int
|
||||
CommitsBehind int
|
||||
|
@ -41,7 +42,7 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error {
|
|||
MergedCommitID string `xorm:"VARCHAR(40)"`
|
||||
}
|
||||
|
||||
if err := x.Sync2(new(models.PullRequest)); err != nil {
|
||||
if err := x.Sync2(new(PullRequest)); err != nil {
|
||||
return fmt.Errorf("Sync2: %v", err)
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,7 @@ func addCommitDivergenceToPulls(x *xorm.Engine) error {
|
|||
if err := sess.Begin(); err != nil {
|
||||
return err
|
||||
}
|
||||
var results = make([]*models.PullRequest, 0, batchSize)
|
||||
var results = make([]*PullRequest, 0, batchSize)
|
||||
err := sess.Where("has_merged = ?", false).OrderBy("id").Limit(batchSize, last).Find(&results)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -6,9 +6,11 @@ package migrations
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
@ -32,6 +34,16 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
|
|||
Name string
|
||||
}
|
||||
|
||||
// UserPath returns the path absolute path of user repositories.
|
||||
UserPath := func(userName string) string {
|
||||
return filepath.Join(setting.RepoRootPath, strings.ToLower(userName))
|
||||
}
|
||||
|
||||
// RepoPath returns repository path by given user and repository name.
|
||||
RepoPath := func(userName, repoName string) string {
|
||||
return filepath.Join(UserPath(userName), strings.ToLower(repoName)+".git")
|
||||
}
|
||||
|
||||
// Update release sha1
|
||||
const batchSize = 100
|
||||
sess := x.NewSession()
|
||||
|
@ -87,7 +99,7 @@ func fixReleaseSha1OnReleaseTable(x *xorm.Engine) error {
|
|||
userCache[repo.OwnerID] = user
|
||||
}
|
||||
|
||||
gitRepo, err = git.OpenRepository(models.RepoPath(user.Name, repo.Name))
|
||||
gitRepo, err = git.OpenRepository(RepoPath(user.Name, repo.Name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ package migrations
|
|||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"xorm.io/xorm"
|
||||
|
@ -23,6 +23,12 @@ func deleteOrphanedAttachments(x *xorm.Engine) error {
|
|||
CommentID int64
|
||||
}
|
||||
|
||||
// AttachmentLocalPath returns where attachment is stored in local file
|
||||
// system based on given UUID.
|
||||
AttachmentLocalPath := func(uuid string) string {
|
||||
return path.Join(setting.AttachmentPath, uuid[0:1], uuid[1:2], uuid)
|
||||
}
|
||||
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
|
@ -52,7 +58,7 @@ func deleteOrphanedAttachments(x *xorm.Engine) error {
|
|||
}
|
||||
|
||||
for _, attachment := range attachements {
|
||||
if err := os.RemoveAll(models.AttachmentLocalPath(attachment.UUID)); err != nil {
|
||||
if err := os.RemoveAll(AttachmentLocalPath(attachment.UUID)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,20 +5,25 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func addTaskTable(x *xorm.Engine) error {
|
||||
// TaskType defines task type
|
||||
type TaskType int
|
||||
|
||||
// TaskStatus defines task status
|
||||
type TaskStatus int
|
||||
|
||||
type Task struct {
|
||||
ID int64
|
||||
DoerID int64 `xorm:"index"` // operator
|
||||
OwnerID int64 `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
|
||||
RepoID int64 `xorm:"index"`
|
||||
Type structs.TaskType
|
||||
Status structs.TaskStatus `xorm:"index"`
|
||||
Type TaskType
|
||||
Status TaskStatus `xorm:"index"`
|
||||
StartTime timeutil.TimeStamp
|
||||
EndTime timeutil.TimeStamp
|
||||
PayloadContent string `xorm:"TEXT"`
|
||||
|
|
Loading…
Reference in a new issue