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,6 +4,8 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
@@ -18,7 +20,7 @@ func (pullAutoMerge) TableName() string {
return "pull_auto_merge"
}
func AddDeleteBranchAfterMergeForAutoMerge(x base.EngineMigration) error {
func AddDeleteBranchAfterMergeForAutoMerge(_ context.Context, x base.EngineMigration) error {
_, err := x.SyncWithOptions(xorm.SyncOptions{
IgnoreConstrains: true,
IgnoreIndices: true,
+3 -1
View File
@@ -4,10 +4,12 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
)
func MovePinOrderToTableIssuePin(x base.EngineMigration) error {
func MovePinOrderToTableIssuePin(_ context.Context, x base.EngineMigration) error {
type IssuePin struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"UNIQUE(s) NOT NULL"`
+6 -2
View File
@@ -3,9 +3,13 @@
package v1_24
import "gitea.dev/modelmigration/base"
import (
"context"
func UpdateOwnerIDOfRepoLevelActionsTables(x base.EngineMigration) error {
"gitea.dev/modelmigration/base"
)
func UpdateOwnerIDOfRepoLevelActionsTables(_ context.Context, x base.EngineMigration) error {
if _, err := x.Exec("UPDATE `action_runner` SET `owner_id` = 0 WHERE `repo_id` > 0 AND `owner_id` > 0"); err != nil {
return err
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddEphemeralToActionRunner(x base.EngineMigration) error {
func AddEphemeralToActionRunner(_ context.Context, x base.EngineMigration) error {
type ActionRunner struct {
Ephemeral bool `xorm:"ephemeral NOT NULL DEFAULT false"`
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddDescriptionForSecretsAndVariables(x base.EngineMigration) error {
func AddDescriptionForSecretsAndVariables(_ context.Context, x base.EngineMigration) error {
type Secret struct {
Description string `xorm:"TEXT"`
}
+3 -1
View File
@@ -4,6 +4,8 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/timeutil"
@@ -51,6 +53,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,12 +4,14 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddRepoUnitAnonymousAccessMode(x base.EngineMigration) error {
func AddRepoUnitAnonymousAccessMode(_ context.Context, x base.EngineMigration) error {
type RepoUnit struct { //revive:disable-line:exported
AnonymousAccessMode int `xorm:"NOT NULL DEFAULT 0"`
}
+3 -1
View File
@@ -4,12 +4,14 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"xorm.io/xorm"
)
func AddExclusiveOrderColumnToLabelTable(x base.EngineMigration) error {
func AddExclusiveOrderColumnToLabelTable(_ context.Context, x base.EngineMigration) error {
type Label struct {
ExclusiveOrder int `xorm:"DEFAULT 0"`
}
+3 -1
View File
@@ -4,13 +4,15 @@
package v1_24
import (
"context"
"gitea.dev/modelmigration/base"
"gitea.dev/modules/json"
"xorm.io/xorm"
)
func MigrateSkipTwoFactor(x base.EngineMigration) error {
func MigrateSkipTwoFactor(_ context.Context, x base.EngineMigration) error {
type LoginSource struct {
TwoFactorPolicy string `xorm:"two_factor_policy NOT NULL DEFAULT ''"`
}