aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-07-15 05:15:59 +0800
committerGitHub <noreply@github.com>2024-07-14 17:15:59 -0400
commit0d08bb6112884411eb4f58b056278d3c824a8fc0 (patch)
treebb68fa2b7ec03f087666f28c0d0775427f99473c /models
parent1064e817c4a6fa6eb5170143150505503c4ef6ed (diff)
downloadgitea-0d08bb6112884411eb4f58b056278d3c824a8fc0.tar.gz
gitea-0d08bb6112884411eb4f58b056278d3c824a8fc0.zip
Upgrade xorm to v1.3.9 and improve some migrations Sync (#29899)
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models')
-rw-r--r--models/migrations/v1_21/v279.go6
-rw-r--r--models/migrations/v1_22/v284.go6
-rw-r--r--models/migrations/v1_22/v285.go6
-rw-r--r--models/migrations/v1_22/v286.go5
-rw-r--r--models/migrations/v1_22/v289.go5
-rw-r--r--models/migrations/v1_22/v290.go9
-rw-r--r--models/migrations/v1_22/v291.go6
7 files changed, 36 insertions, 7 deletions
diff --git a/models/migrations/v1_21/v279.go b/models/migrations/v1_21/v279.go
index 19647225c9..2abd1bbe84 100644
--- a/models/migrations/v1_21/v279.go
+++ b/models/migrations/v1_21/v279.go
@@ -12,5 +12,9 @@ func AddIndexToActionUserID(x *xorm.Engine) error {
UserID int64 `xorm:"INDEX"`
}
- return x.Sync(new(Action))
+ _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreDropIndices: true,
+ IgnoreConstrains: true,
+ }, new(Action))
+ return err
}
diff --git a/models/migrations/v1_22/v284.go b/models/migrations/v1_22/v284.go
index 1a4c786964..2b95078980 100644
--- a/models/migrations/v1_22/v284.go
+++ b/models/migrations/v1_22/v284.go
@@ -10,5 +10,9 @@ func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x *xorm.Engine) error {
type ProtectedBranch struct {
IgnoreStaleApprovals bool `xorm:"NOT NULL DEFAULT false"`
}
- return x.Sync(new(ProtectedBranch))
+ _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreIndices: true,
+ IgnoreConstrains: true,
+ }, new(ProtectedBranch))
+ return err
}
diff --git a/models/migrations/v1_22/v285.go b/models/migrations/v1_22/v285.go
index c0dacd40bc..a55cc17c04 100644
--- a/models/migrations/v1_22/v285.go
+++ b/models/migrations/v1_22/v285.go
@@ -14,5 +14,9 @@ func AddPreviousDurationToActionRun(x *xorm.Engine) error {
PreviousDuration time.Duration
}
- return x.Sync(&ActionRun{})
+ _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreIndices: true,
+ IgnoreConstrains: true,
+ }, &ActionRun{})
+ return err
}
diff --git a/models/migrations/v1_22/v286.go b/models/migrations/v1_22/v286.go
index 6ad669f27c..1fcde33202 100644
--- a/models/migrations/v1_22/v286.go
+++ b/models/migrations/v1_22/v286.go
@@ -86,7 +86,10 @@ func addObjectFormatNameToRepository(x *xorm.Engine) error {
ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"`
}
- if err := x.Sync(new(Repository)); err != nil {
+ if _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreIndices: true,
+ IgnoreConstrains: true,
+ }, new(Repository)); err != nil {
return err
}
diff --git a/models/migrations/v1_22/v289.go b/models/migrations/v1_22/v289.go
index e2dfc48715..b9941aadd9 100644
--- a/models/migrations/v1_22/v289.go
+++ b/models/migrations/v1_22/v289.go
@@ -10,7 +10,10 @@ func AddDefaultWikiBranch(x *xorm.Engine) error {
ID int64
DefaultWikiBranch string
}
- if err := x.Sync(&Repository{}); err != nil {
+ if _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreIndices: true,
+ IgnoreConstrains: true,
+ }, &Repository{}); err != nil {
return err
}
_, err := x.Exec("UPDATE `repository` SET default_wiki_branch = 'master' WHERE (default_wiki_branch IS NULL) OR (default_wiki_branch = '')")
diff --git a/models/migrations/v1_22/v290.go b/models/migrations/v1_22/v290.go
index e9b7f504ba..9c54d4e87c 100644
--- a/models/migrations/v1_22/v290.go
+++ b/models/migrations/v1_22/v290.go
@@ -13,5 +13,12 @@ type HookTask struct {
func AddPayloadVersionToHookTaskTable(x *xorm.Engine) error {
// create missing column
- return x.Sync(new(HookTask))
+ if _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreIndices: true,
+ IgnoreConstrains: true,
+ }, new(HookTask)); err != nil {
+ return err
+ }
+ _, err := x.Exec("UPDATE hook_task SET payload_version = 1 WHERE payload_version IS NULL")
+ return err
}
diff --git a/models/migrations/v1_22/v291.go b/models/migrations/v1_22/v291.go
index 0bfffe5d05..74726fae96 100644
--- a/models/migrations/v1_22/v291.go
+++ b/models/migrations/v1_22/v291.go
@@ -10,5 +10,9 @@ func AddCommentIDIndexofAttachment(x *xorm.Engine) error {
CommentID int64 `xorm:"INDEX"`
}
- return x.Sync(&Attachment{})
+ _, err := x.SyncWithOptions(xorm.SyncOptions{
+ IgnoreDropIndices: true,
+ IgnoreConstrains: true,
+ }, &Attachment{})
+ return err
}