refactor(modelmigration): thread context through migration functions (#38758)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
Copilot
2026-08-03 08:13:15 +00:00
committed by GitHub
co-authored by wxiaoguang
parent e23fe79e5e
commit ac49dbe1a2
304 changed files with 1070 additions and 449 deletions
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddContentVersionToIssueAndComment(x base.EngineMigration) error {
func AddContentVersionToIssueAndComment(_ context.Context, x base.EngineMigration) error {
type Issue struct {
ContentVersion int `xorm:"NOT NULL DEFAULT 0"`
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddForcePushBranchProtection(x base.EngineMigration) error {
func AddForcePushBranchProtection(_ context.Context, x base.EngineMigration) error {
type ProtectedBranch struct {
CanForcePush bool `xorm:"NOT NULL DEFAULT false"`
EnableForcePushAllowlist bool `xorm:"NOT NULL DEFAULT false"`
+3 -1
View File
@@ -4,13 +4,15 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
// AddSkipSeconderyAuthToOAuth2ApplicationTable: add SkipSecondaryAuthorization column, setting existing rows to false
func AddSkipSecondaryAuthColumnToOAuth2ApplicationTable(x base.EngineMigration) error {
func AddSkipSecondaryAuthColumnToOAuth2ApplicationTable(_ context.Context, x base.EngineMigration) error {
type oauth2Application struct {
SkipSecondaryAuthorization bool `xorm:"NOT NULL DEFAULT FALSE"`
}
+3 -1
View File
@@ -4,13 +4,15 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
"xorm.io/xorm"
)
func AddIndexToActionTaskStoppedLogExpired(x base.EngineMigration) error {
func AddIndexToActionTaskStoppedLogExpired(_ context.Context, x base.EngineMigration) error {
type ActionTask struct {
Stopped timeutil.TimeStamp `xorm:"index(stopped_log_expired)"`
LogExpired bool `xorm:"index(stopped_log_expired)"`
+1 -1
View File
@@ -47,5 +47,5 @@ func Test_AddIndexToActionTaskStoppedLogExpired(t *testing.T) {
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ActionTask))
defer deferable()
assert.NoError(t, AddIndexToActionTaskStoppedLogExpired(x))
assert.NoError(t, AddIndexToActionTaskStoppedLogExpired(t.Context(), x))
}
+3 -1
View File
@@ -4,6 +4,8 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
@@ -16,7 +18,7 @@ type CommentMetaData struct {
ProjectTitle string `json:"project_title"`
}
func AddCommentMetaDataColumn(x base.EngineMigration) error {
func AddCommentMetaDataColumn(_ context.Context, x base.EngineMigration) error {
type Comment struct {
CommentMetaData *CommentMetaData `xorm:"JSON TEXT"` // put all non-index metadata in a single field
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddIndexForReleaseSha1(x base.EngineMigration) error {
func AddIndexForReleaseSha1(_ context.Context, x base.EngineMigration) error {
type Release struct {
Sha1 string `xorm:"INDEX VARCHAR(64)"`
}
+1 -1
View File
@@ -36,5 +36,5 @@ func Test_AddIndexForReleaseSha1(t *testing.T) {
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(Release))
defer deferable()
assert.NoError(t, AddIndexForReleaseSha1(x))
assert.NoError(t, AddIndexForReleaseSha1(t.Context(), x))
}
+3 -1
View File
@@ -4,11 +4,13 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
)
func AddRepositoryLicenses(x base.EngineMigration) error {
func AddRepositoryLicenses(_ context.Context, x base.EngineMigration) error {
type RepoLicense struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"UNIQUE(s) NOT NULL"`
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddBlockAdminMergeOverrideBranchProtection(x base.EngineMigration) error {
func AddBlockAdminMergeOverrideBranchProtection(_ context.Context, x base.EngineMigration) error {
type ProtectedBranch struct {
BlockAdminMergeOverride bool `xorm:"NOT NULL DEFAULT false"`
}
+3 -1
View File
@@ -4,11 +4,13 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
)
func FixMilestoneNoDueDate(x base.EngineMigration) error {
func FixMilestoneNoDueDate(_ context.Context, x base.EngineMigration) error {
type Milestone struct {
DeadlineUnix timeutil.TimeStamp
}
+3 -1
View File
@@ -4,6 +4,8 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
@@ -47,6 +49,6 @@ func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {
return indices
}
func AddNewIndexForUserDashboard(x base.EngineMigration) error {
func AddNewIndexForUserDashboard(_ context.Context, x base.EngineMigration) error {
return x.Sync(new(improveActionTableIndicesAction))
}
+3 -1
View File
@@ -4,6 +4,8 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
@@ -72,6 +74,6 @@ func (*improveNotificationTableIndicesAction) TableIndices() []*schemas.Index {
return indices
}
func ImproveNotificationTableIndices(x base.EngineMigration) error {
func ImproveNotificationTableIndices(_ context.Context, x base.EngineMigration) error {
return x.Sync(&improveNotificationTableIndicesAction{})
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddPriorityToProtectedBranch(x base.EngineMigration) error {
func AddPriorityToProtectedBranch(_ context.Context, x base.EngineMigration) error {
type ProtectedBranch struct {
Priority int64 `xorm:"NOT NULL DEFAULT 0"`
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_23
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddTimeEstimateColumnToIssueTable(x base.EngineMigration) error {
func AddTimeEstimateColumnToIssueTable(_ context.Context, x base.EngineMigration) error {
type Issue struct {
TimeEstimate int64 `xorm:"NOT NULL DEFAULT 0"`
}