summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-07-22 16:27:22 +0200
committerGitHub <noreply@github.com>2020-07-22 09:27:22 -0500
commit2753d72773ae75e326d342757aa0159642a4a794 (patch)
tree41137eae1e0d423d4ea22434fcd318aca3ade05f
parent8e20daaede6831be1309f5b27af382bbd1d82aad (diff)
downloadgitea-2753d72773ae75e326d342757aa0159642a4a794.tar.gz
gitea-2753d72773ae75e326d342757aa0159642a4a794.zip
Migrations (v82,v96,v99,v136) remove dependencies (#12286)
* remove dependencys * add missing fields * CI.restart()
-rw-r--r--models/migrations/v136.go9
-rw-r--r--models/migrations/v82.go16
-rw-r--r--models/migrations/v96.go10
-rw-r--r--models/migrations/v99.go11
4 files changed, 35 insertions, 11 deletions
diff --git a/models/migrations/v136.go b/models/migrations/v136.go
index 3f718798ba..2203f15386 100644
--- a/models/migrations/v136.go
+++ b/models/migrations/v136.go
@@ -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
diff --git a/models/migrations/v82.go b/models/migrations/v82.go
index 2daa86ab07..67bb0cb8c9 100644
--- a/models/migrations/v82.go
+++ b/models/migrations/v82.go
@@ -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
}
diff --git a/models/migrations/v96.go b/models/migrations/v96.go
index 7a1684354a..9840248f61 100644
--- a/models/migrations/v96.go
+++ b/models/migrations/v96.go
@@ -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
}
}
diff --git a/models/migrations/v99.go b/models/migrations/v99.go
index 00b4509721..b6f6babcee 100644
--- a/models/migrations/v99.go
+++ b/models/migrations/v99.go
@@ -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"`