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:
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddIndexForHookTask(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddIndexForHookTask(_ context.Context, x base.EngineMigration) error {
|
||||
type HookTask struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
HookID int64 `xorm:"index"`
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
func AlterPackageVersionMetadataToLongText(x base.EngineMigration) error {
|
||||
func AlterPackageVersionMetadataToLongText(_ context.Context, x base.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
@@ -51,7 +52,7 @@ func batchProcess[T any](x base.EngineMigration, buf []T, query func(limit, star
|
||||
}
|
||||
}
|
||||
|
||||
func AddHeaderAuthorizationEncryptedColWebhook(x base.EngineMigration) error {
|
||||
func AddHeaderAuthorizationEncryptedColWebhook(_ context.Context, x base.EngineMigration) error {
|
||||
// Add the column to the table
|
||||
type Webhook struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
|
||||
@@ -45,7 +45,7 @@ func Test_AddHeaderAuthorizationEncryptedColWebhook(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := AddHeaderAuthorizationEncryptedColWebhook(x); err != nil {
|
||||
if err := AddHeaderAuthorizationEncryptedColWebhook(t.Context(), x); err != nil {
|
||||
assert.NoError(t, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func CreatePackageCleanupRuleTable(x base.EngineMigration) error {
|
||||
func CreatePackageCleanupRuleTable(_ context.Context, x base.EngineMigration) error {
|
||||
type PackageCleanupRule struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
Enabled bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddIndexForAccessToken(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddIndexForAccessToken(_ context.Context, x base.EngineMigration) error {
|
||||
type AccessToken struct {
|
||||
TokenLastEight string `xorm:"INDEX token_last_eight"`
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func CreateSecretsTable(x base.EngineMigration) error {
|
||||
func CreateSecretsTable(_ context.Context, x base.EngineMigration) error {
|
||||
type Secret struct {
|
||||
ID int64
|
||||
OwnerID int64 `xorm:"INDEX UNIQUE(owner_repo_name) NOT NULL"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func DropForeignReferenceTable(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func DropForeignReferenceTable(_ context.Context, x base.EngineMigration) error {
|
||||
// Drop the table introduced in `v211`, it's considered badly designed and doesn't look like to be used.
|
||||
// See: https://github.com/go-gitea/gitea/issues/21086#issuecomment-1318217453
|
||||
type ForeignReference struct{}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
// AddUpdatedUnixToLFSMetaObject adds an updated column to the LFSMetaObject to allow for garbage collection
|
||||
func AddUpdatedUnixToLFSMetaObject(x base.EngineMigration) error {
|
||||
func AddUpdatedUnixToLFSMetaObject(_ context.Context, x base.EngineMigration) error {
|
||||
// Drop the table introduced in `v211`, it's considered badly designed and doesn't look like to be used.
|
||||
// See: https://github.com/go-gitea/gitea/issues/21086#issuecomment-1318217453
|
||||
// LFSMetaObject stores metadata for LFS tracked files.
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddScopeForAccessTokens(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddScopeForAccessTokens(_ context.Context, x base.EngineMigration) error {
|
||||
type AccessToken struct {
|
||||
Scope string
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func AddActionsTables(x base.EngineMigration) error {
|
||||
func AddActionsTables(_ context.Context, x base.EngineMigration) error {
|
||||
type ActionRunner struct {
|
||||
ID int64
|
||||
UUID string `xorm:"CHAR(36) UNIQUE"`
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
// AddCardTypeToProjectTable: add CardType column, setting existing rows to CardTypeTextOnly
|
||||
func AddCardTypeToProjectTable(x base.EngineMigration) error {
|
||||
func AddCardTypeToProjectTable(_ context.Context, x base.EngineMigration) error {
|
||||
type Project struct {
|
||||
CardType int `xorm:"NOT NULL DEFAULT 0"`
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
package v1_19
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
// AlterPublicGPGKeyImportContentFieldToMediumText: set GPGKeyImport Content field to MEDIUMTEXT
|
||||
func AlterPublicGPGKeyImportContentFieldToMediumText(x base.EngineMigration) error {
|
||||
func AlterPublicGPGKeyImportContentFieldToMediumText(_ context.Context, x base.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_19
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddExclusiveLabel(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddExclusiveLabel(_ context.Context, x base.EngineMigration) error {
|
||||
type Label struct {
|
||||
Exclusive bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user