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,7 @@
|
||||
package v1_10
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func UpdateMigrationServiceTypes(x base.EngineMigration) error {
|
||||
func UpdateMigrationServiceTypes(_ context.Context, x base.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ID int64
|
||||
OriginalServiceType int `xorm:"index default(0)"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func ChangeSomeColumnsLengthOfExternalLoginUser(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func ChangeSomeColumnsLengthOfExternalLoginUser(_ context.Context, x base.EngineMigration) error {
|
||||
type ExternalLoginUser struct {
|
||||
AccessToken string `xorm:"TEXT"`
|
||||
AccessTokenSecret string `xorm:"TEXT"`
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package v1_10
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
|
||||
@@ -14,7 +15,7 @@ func hashContext(context string) string {
|
||||
return fmt.Sprintf("%x", sha1.Sum([]byte(context)))
|
||||
}
|
||||
|
||||
func AddCommitStatusContext(x base.EngineMigration) error {
|
||||
func AddCommitStatusContext(_ context.Context, x base.EngineMigration) error {
|
||||
type CommitStatus struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
ContextHash string `xorm:"char(40) index"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddOriginalMigrationInfo(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddOriginalMigrationInfo(_ context.Context, x base.EngineMigration) error {
|
||||
// Issue see models/issue.go
|
||||
type Issue struct {
|
||||
OriginalAuthor string
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func ChangeSomeColumnsLengthOfRepo(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func ChangeSomeColumnsLengthOfRepo(_ context.Context, x base.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
Description string `xorm:"TEXT"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddIndexOnRepositoryAndComment(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddIndexOnRepositoryAndComment(_ context.Context, x base.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
OwnerID int64 `xorm:"index"`
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
package v1_10
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
func RemoveLingeringIndexStatus(x base.EngineMigration) error {
|
||||
func RemoveLingeringIndexStatus(_ context.Context, x base.EngineMigration) error {
|
||||
_, err := x.Exec(builder.Delete(builder.NotIn("`repo_id`", builder.Select("`id`").From("`repository`"))).From("`repo_indexer_status`"))
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddEmailNotificationEnabledToUser(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddEmailNotificationEnabledToUser(_ context.Context, x base.EngineMigration) error {
|
||||
// User see models/user.go
|
||||
type User struct {
|
||||
EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddStatusCheckColumnsForProtectedBranches(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddStatusCheckColumnsForProtectedBranches(_ context.Context, x base.EngineMigration) error {
|
||||
type ProtectedBranch struct {
|
||||
EnableStatusCheck bool `xorm:"NOT NULL DEFAULT false"`
|
||||
StatusCheckContexts []string `xorm:"JSON TEXT"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddCrossReferenceColumns(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddCrossReferenceColumns(_ context.Context, x base.EngineMigration) error {
|
||||
// Comment see models/comment.go
|
||||
type Comment struct {
|
||||
RefRepoID int64 `xorm:"index"`
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package v1_10
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
func DeleteOrphanedAttachments(x base.EngineMigration) error {
|
||||
func DeleteOrphanedAttachments(_ context.Context, x base.EngineMigration) error {
|
||||
type Attachment struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
UUID string `xorm:"uuid UNIQUE"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddRepoAdminChangeTeamAccessColumnForUser(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddRepoAdminChangeTeamAccessColumnForUser(_ context.Context, x base.EngineMigration) error {
|
||||
type User struct {
|
||||
RepoAdminChangeTeamAccess bool `xorm:"NOT NULL DEFAULT false"`
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_10
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddOriginalAuthorOnMigratedReleases(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddOriginalAuthorOnMigratedReleases(_ context.Context, x base.EngineMigration) error {
|
||||
type Release struct {
|
||||
ID int64
|
||||
OriginalAuthor string
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
package v1_10
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func AddTaskTable(x base.EngineMigration) error {
|
||||
func AddTaskTable(_ context.Context, x base.EngineMigration) error {
|
||||
// TaskType defines task type
|
||||
type TaskType int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user