mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-23 21:23:41 +09:00
refactor(modelmigration): thread context through migration functions (#38758)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -4,10 +4,12 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func DropColumnHeadUserNameOnPullRequest(x base.EngineMigration) error {
|
||||
func DropColumnHeadUserNameOnPullRequest(_ context.Context, x base.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddWhitelistDeployKeysToBranches(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddWhitelistDeployKeysToBranches(_ context.Context, x base.EngineMigration) error {
|
||||
type ProtectedBranch struct {
|
||||
ID int64
|
||||
WhitelistDeployKeys bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func RemoveLabelUneededCols(x base.EngineMigration) error {
|
||||
func RemoveLabelUneededCols(_ context.Context, x base.EngineMigration) error {
|
||||
// Make sure the columns exist before dropping them
|
||||
type Label struct {
|
||||
QueryString string
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddTeamIncludesAllRepositories(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddTeamIncludesAllRepositories(_ context.Context, x base.EngineMigration) error {
|
||||
type Team struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
IncludesAllRepositories bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
// RepoWatchMode specifies what kind of watch the user has on a repository
|
||||
type RepoWatchMode int8
|
||||
@@ -14,7 +18,7 @@ type Watch struct {
|
||||
Mode RepoWatchMode `xorm:"SMALLINT NOT NULL DEFAULT 1"`
|
||||
}
|
||||
|
||||
func AddModeColumnToWatch(x base.EngineMigration) error {
|
||||
func AddModeColumnToWatch(_ context.Context, x base.EngineMigration) error {
|
||||
if err := x.Sync(new(Watch)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddTemplateToRepo(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddTemplateToRepo(_ context.Context, x base.EngineMigration) error {
|
||||
type Repository struct {
|
||||
IsTemplate bool `xorm:"INDEX NOT NULL DEFAULT false"`
|
||||
TemplateID int64 `xorm:"INDEX"`
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddCommentIDOnNotification(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddCommentIDOnNotification(_ context.Context, x base.EngineMigration) error {
|
||||
type Notification struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
CommentID int64
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func AddCanCreateOrgRepoColumnForTeam(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddCanCreateOrgRepoColumnForTeam(_ context.Context, x base.EngineMigration) error {
|
||||
type Team struct {
|
||||
CanCreateOrgRepo bool `xorm:"NOT NULL DEFAULT false"`
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
func ChangeReviewContentToText(x base.EngineMigration) error {
|
||||
func ChangeReviewContentToText(_ context.Context, x base.EngineMigration) error {
|
||||
switch x.Dialect().URI().DBType {
|
||||
case schemas.MYSQL:
|
||||
_, err := x.Exec("ALTER TABLE review MODIFY COLUMN content TEXT")
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func AddBranchProtectionCanPushAndEnableWhitelist(x base.EngineMigration) error {
|
||||
func AddBranchProtectionCanPushAndEnableWhitelist(_ context.Context, x base.EngineMigration) error {
|
||||
type ProtectedBranch struct {
|
||||
CanPush bool `xorm:"NOT NULL DEFAULT false"`
|
||||
EnableApprovalsWhitelist bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -14,7 +15,7 @@ import (
|
||||
"xorm.io/builder"
|
||||
)
|
||||
|
||||
func RemoveAttachmentMissedRepo(x base.EngineMigration) error {
|
||||
func RemoveAttachmentMissedRepo(_ context.Context, x base.EngineMigration) error {
|
||||
type Attachment struct {
|
||||
UUID string `xorm:"uuid"`
|
||||
}
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func FeatureChangeTargetBranch(x base.EngineMigration) error {
|
||||
func FeatureChangeTargetBranch(_ context.Context, x base.EngineMigration) error {
|
||||
type Comment struct {
|
||||
OldRef string
|
||||
NewRef string
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func SanitizeOriginalURL(x base.EngineMigration) error {
|
||||
func SanitizeOriginalURL(_ context.Context, x base.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ID int64
|
||||
OriginalURL string `xorm:"VARCHAR(2048)"`
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package v1_11
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -18,7 +19,7 @@ import (
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
func RenameExistingUserAvatarName(x base.EngineMigration) error {
|
||||
func RenameExistingUserAvatarName(_ context.Context, x base.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_11
|
||||
|
||||
import "gitea.dev/modelmigration/base"
|
||||
import (
|
||||
"context"
|
||||
|
||||
func ExtendTrackedTimes(x base.EngineMigration) error {
|
||||
"gitea.dev/modelmigration/base"
|
||||
)
|
||||
|
||||
func ExtendTrackedTimes(_ context.Context, x base.EngineMigration) error {
|
||||
type TrackedTime struct {
|
||||
Time int64 `xorm:"NOT NULL"`
|
||||
Deleted bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
||||
Reference in New Issue
Block a user