Skip to content

Commit 0d08bb6

Browse files
lunny6543
andauthored
Upgrade xorm to v1.3.9 and improve some migrations Sync (#29899)
Co-authored-by: 6543 <[email protected]>
1 parent 1064e81 commit 0d08bb6

File tree

9 files changed

+39
-10
lines changed

9 files changed

+39
-10
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ require (
123123
mvdan.cc/xurls/v2 v2.5.0
124124
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251
125125
xorm.io/builder v0.3.13
126-
xorm.io/xorm v1.3.8
126+
xorm.io/xorm v1.3.9
127127
)
128128

129129
require (

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1064,5 +1064,5 @@ strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251 h1:mUcz5b3
10641064
strk.kbt.io/projects/go/libravatar v0.0.0-20191008002943-06d1c002b251/go.mod h1:FJGmPh3vz9jSos1L/F91iAgnC/aejc0wIIrF2ZwJxdY=
10651065
xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
10661066
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
1067-
xorm.io/xorm v1.3.8 h1:CJmplmWqfSRpLWSPMmqz+so8toBp3m7ehuRehIWedZo=
1068-
xorm.io/xorm v1.3.8/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=
1067+
xorm.io/xorm v1.3.9 h1:TUovzS0ko+IQ1XnNLfs5dqK1cJl1H5uHpWbWqAQ04nU=
1068+
xorm.io/xorm v1.3.9/go.mod h1:LsCCffeeYp63ssk0pKumP6l96WZcHix7ChpurcLNuMw=

models/migrations/v1_21/v279.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ func AddIndexToActionUserID(x *xorm.Engine) error {
1212
UserID int64 `xorm:"INDEX"`
1313
}
1414

15-
return x.Sync(new(Action))
15+
_, err := x.SyncWithOptions(xorm.SyncOptions{
16+
IgnoreDropIndices: true,
17+
IgnoreConstrains: true,
18+
}, new(Action))
19+
return err
1620
}

models/migrations/v1_22/v284.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x *xorm.Engine) error {
1010
type ProtectedBranch struct {
1111
IgnoreStaleApprovals bool `xorm:"NOT NULL DEFAULT false"`
1212
}
13-
return x.Sync(new(ProtectedBranch))
13+
_, err := x.SyncWithOptions(xorm.SyncOptions{
14+
IgnoreIndices: true,
15+
IgnoreConstrains: true,
16+
}, new(ProtectedBranch))
17+
return err
1418
}

models/migrations/v1_22/v285.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ func AddPreviousDurationToActionRun(x *xorm.Engine) error {
1414
PreviousDuration time.Duration
1515
}
1616

17-
return x.Sync(&ActionRun{})
17+
_, err := x.SyncWithOptions(xorm.SyncOptions{
18+
IgnoreIndices: true,
19+
IgnoreConstrains: true,
20+
}, &ActionRun{})
21+
return err
1822
}

models/migrations/v1_22/v286.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ func addObjectFormatNameToRepository(x *xorm.Engine) error {
8686
ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"`
8787
}
8888

89-
if err := x.Sync(new(Repository)); err != nil {
89+
if _, err := x.SyncWithOptions(xorm.SyncOptions{
90+
IgnoreIndices: true,
91+
IgnoreConstrains: true,
92+
}, new(Repository)); err != nil {
9093
return err
9194
}
9295

models/migrations/v1_22/v289.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ func AddDefaultWikiBranch(x *xorm.Engine) error {
1010
ID int64
1111
DefaultWikiBranch string
1212
}
13-
if err := x.Sync(&Repository{}); err != nil {
13+
if _, err := x.SyncWithOptions(xorm.SyncOptions{
14+
IgnoreIndices: true,
15+
IgnoreConstrains: true,
16+
}, &Repository{}); err != nil {
1417
return err
1518
}
1619
_, err := x.Exec("UPDATE `repository` SET default_wiki_branch = 'master' WHERE (default_wiki_branch IS NULL) OR (default_wiki_branch = '')")

models/migrations/v1_22/v290.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,12 @@ type HookTask struct {
1313

1414
func AddPayloadVersionToHookTaskTable(x *xorm.Engine) error {
1515
// create missing column
16-
return x.Sync(new(HookTask))
16+
if _, err := x.SyncWithOptions(xorm.SyncOptions{
17+
IgnoreIndices: true,
18+
IgnoreConstrains: true,
19+
}, new(HookTask)); err != nil {
20+
return err
21+
}
22+
_, err := x.Exec("UPDATE hook_task SET payload_version = 1 WHERE payload_version IS NULL")
23+
return err
1724
}

models/migrations/v1_22/v291.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ func AddCommentIDIndexofAttachment(x *xorm.Engine) error {
1010
CommentID int64 `xorm:"INDEX"`
1111
}
1212

13-
return x.Sync(&Attachment{})
13+
_, err := x.SyncWithOptions(xorm.SyncOptions{
14+
IgnoreDropIndices: true,
15+
IgnoreConstrains: true,
16+
}, &Attachment{})
17+
return err
1418
}

0 commit comments

Comments
 (0)