mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-16 01:43:24 +09:00
refactor(modelmigration): thread context through migration functions (#38758)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
@@ -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 ''"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user