This commit is contained in:
@@ -6,9 +6,9 @@ package v1_22
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
base.MainTest(m)
|
||||
migrationtest.MainTest(m)
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func RenameUserThemes(x *xorm.Engine) error {
|
||||
func RenameUserThemes(x db.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func CreateAuthTokenTable(x *xorm.Engine) error {
|
||||
func CreateAuthTokenTable(x db.EngineMigration) error {
|
||||
type AuthToken struct {
|
||||
ID string `xorm:"pk"`
|
||||
TokenHash string
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func AddIndexToPullAutoMergeDoerID(x *xorm.Engine) error {
|
||||
func AddIndexToPullAutoMergeDoerID(x db.EngineMigration) error {
|
||||
type PullAutoMerge struct {
|
||||
DoerID int64 `xorm:"INDEX NOT NULL"`
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@ package v1_22
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
func AddCombinedIndexToIssueUser(x *xorm.Engine) error {
|
||||
func AddCombinedIndexToIssueUser(x db.EngineMigration) error {
|
||||
type OldIssueUser struct {
|
||||
IssueID int64
|
||||
UID int64
|
||||
|
||||
@@ -6,7 +6,7 @@ package v1_22
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -21,7 +21,7 @@ func Test_AddCombinedIndexToIssueUser(t *testing.T) {
|
||||
}
|
||||
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(IssueUser))
|
||||
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(IssueUser))
|
||||
defer deferable()
|
||||
|
||||
assert.NoError(t, AddCombinedIndexToIssueUser(x))
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"gitea.dev/models/db"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x *xorm.Engine) error {
|
||||
func AddIgnoreStaleApprovalsColumnToProtectedBranchTable(x db.EngineMigration) error {
|
||||
type ProtectedBranch struct {
|
||||
IgnoreStaleApprovals bool `xorm:"NOT NULL DEFAULT false"`
|
||||
}
|
||||
|
||||
@@ -6,10 +6,12 @@ package v1_22
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitea.dev/models/db"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func AddPreviousDurationToActionRun(x *xorm.Engine) error {
|
||||
func AddPreviousDurationToActionRun(x db.EngineMigration) error {
|
||||
type ActionRun struct {
|
||||
PreviousDuration time.Duration
|
||||
}
|
||||
|
||||
@@ -6,13 +6,14 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/log"
|
||||
"gitea.dev/modules/setting"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func expandHashReferencesToSha256(x *xorm.Engine) error {
|
||||
func expandHashReferencesToSha256(x db.EngineMigration) error {
|
||||
alteredTables := [][2]string{
|
||||
{"commit_status", "context_hash"},
|
||||
{"comment", "commit_sha"},
|
||||
@@ -81,7 +82,7 @@ func expandHashReferencesToSha256(x *xorm.Engine) error {
|
||||
return db.Commit()
|
||||
}
|
||||
|
||||
func addObjectFormatNameToRepository(x *xorm.Engine) error {
|
||||
func addObjectFormatNameToRepository(x db.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"`
|
||||
}
|
||||
@@ -99,7 +100,7 @@ func addObjectFormatNameToRepository(x *xorm.Engine) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func AdjustDBForSha256(x *xorm.Engine) error {
|
||||
func AdjustDBForSha256(x db.EngineMigration) error {
|
||||
if err := expandHashReferencesToSha256(x); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -6,13 +6,13 @@ package v1_22
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) {
|
||||
func PrepareOldRepository(t *testing.T) (db.EngineMigration, func()) {
|
||||
type Repository struct { // old struct
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func PrepareOldRepository(t *testing.T) (*xorm.Engine, func()) {
|
||||
}
|
||||
|
||||
// Prepare and load the testing database
|
||||
return base.PrepareTestEnv(t, 0,
|
||||
return migrationtest.PrepareTestEnv(t, 0,
|
||||
new(Repository),
|
||||
new(CommitStatus),
|
||||
new(RepoArchiver),
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
type BadgeUnique struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
@@ -16,7 +14,7 @@ func (BadgeUnique) TableName() string {
|
||||
return "badge"
|
||||
}
|
||||
|
||||
func UseSlugInsteadOfIDForBadges(x *xorm.Engine) error {
|
||||
func UseSlugInsteadOfIDForBadges(x db.EngineMigration) error {
|
||||
type Badge struct {
|
||||
Slug string
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -20,7 +20,7 @@ func Test_UpdateBadgeColName(t *testing.T) {
|
||||
}
|
||||
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(Badge))
|
||||
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(Badge))
|
||||
defer deferable()
|
||||
if x == nil || t.Failed() {
|
||||
return
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
type Blocking struct {
|
||||
@@ -21,6 +20,6 @@ func (*Blocking) TableName() string {
|
||||
return "user_blocking"
|
||||
}
|
||||
|
||||
func AddUserBlockingTable(x *xorm.Engine) error {
|
||||
func AddUserBlockingTable(x db.EngineMigration) error {
|
||||
return x.Sync(&Blocking{})
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import "xorm.io/xorm"
|
||||
import (
|
||||
"gitea.dev/models/db"
|
||||
|
||||
func AddDefaultWikiBranch(x *xorm.Engine) error {
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func AddDefaultWikiBranch(x db.EngineMigration) error {
|
||||
type Repository struct {
|
||||
ID int64
|
||||
DefaultWikiBranch string
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"gitea.dev/models/db"
|
||||
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
@@ -11,7 +13,7 @@ type HookTask struct {
|
||||
PayloadVersion int `xorm:"DEFAULT 1"`
|
||||
}
|
||||
|
||||
func AddPayloadVersionToHookTaskTable(x *xorm.Engine) error {
|
||||
func AddPayloadVersionToHookTaskTable(x db.EngineMigration) error {
|
||||
// create missing column
|
||||
if _, err := x.SyncWithOptions(xorm.SyncOptions{
|
||||
IgnoreIndices: true,
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import "xorm.io/xorm"
|
||||
import (
|
||||
"gitea.dev/models/db"
|
||||
|
||||
func AddCommentIDIndexofAttachment(x *xorm.Engine) error {
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
func AddCommentIDIndexofAttachment(x db.EngineMigration) error {
|
||||
type Attachment struct {
|
||||
CommentID int64 `xorm:"INDEX"`
|
||||
}
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
// CheckProjectColumnsConsistency ensures there is exactly one default board per project present
|
||||
func CheckProjectColumnsConsistency(x *xorm.Engine) error {
|
||||
func CheckProjectColumnsConsistency(x db.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
|
||||
@@ -79,7 +78,7 @@ func CheckProjectColumnsConsistency(x *xorm.Engine) error {
|
||||
return removeDuplicatedBoardDefault(x)
|
||||
}
|
||||
|
||||
func removeDuplicatedBoardDefault(x *xorm.Engine) error {
|
||||
func removeDuplicatedBoardDefault(x db.EngineMigration) error {
|
||||
type ProjectInfo struct {
|
||||
ProjectID int64
|
||||
DefaultNum int
|
||||
|
||||
@@ -6,15 +6,15 @@ package v1_22
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"code.gitea.io/gitea/models/project"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
"gitea.dev/models/project"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_CheckProjectColumnsConsistency(t *testing.T) {
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(project.Project), new(project.Column))
|
||||
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(project.Project), new(project.Column))
|
||||
defer deferable()
|
||||
if x == nil || t.Failed() {
|
||||
return
|
||||
|
||||
@@ -6,12 +6,13 @@ package v1_22
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
// AddUniqueIndexForProjectIssue adds unique indexes for project issue table
|
||||
func AddUniqueIndexForProjectIssue(x *xorm.Engine) error {
|
||||
func AddUniqueIndexForProjectIssue(x db.EngineMigration) error {
|
||||
// remove possible duplicated records in table project_issue
|
||||
type result struct {
|
||||
IssueID int64
|
||||
|
||||
@@ -6,7 +6,7 @@ package v1_22
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"xorm.io/xorm/schemas"
|
||||
@@ -20,7 +20,7 @@ func Test_AddUniqueIndexForProjectIssue(t *testing.T) {
|
||||
}
|
||||
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(ProjectIssue))
|
||||
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(ProjectIssue))
|
||||
defer deferable()
|
||||
if x == nil || t.Failed() {
|
||||
return
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import "xorm.io/xorm"
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func AddCommitStatusSummary(x *xorm.Engine) error {
|
||||
func AddCommitStatusSummary(x db.EngineMigration) error {
|
||||
type CommitStatusSummary struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
RepoID int64 `xorm:"INDEX UNIQUE(repo_id_sha)"`
|
||||
@@ -14,5 +14,5 @@ func AddCommitStatusSummary(x *xorm.Engine) error {
|
||||
}
|
||||
// there is no migrations because if there is no data on this table, it will fall back to get data
|
||||
// from commit status
|
||||
return x.Sync2(new(CommitStatusSummary))
|
||||
return x.Sync(new(CommitStatusSummary))
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import "xorm.io/xorm"
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func AddCommitStatusSummary2(x *xorm.Engine) error {
|
||||
func AddCommitStatusSummary2(x db.EngineMigration) error {
|
||||
type CommitStatusSummary struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
TargetURL string `xorm:"TEXT"`
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package v1_22
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/perm"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/perm"
|
||||
)
|
||||
|
||||
func AddRepoUnitEveryoneAccessMode(x *xorm.Engine) error {
|
||||
func AddRepoUnitEveryoneAccessMode(x db.EngineMigration) error {
|
||||
type RepoUnit struct { //revive:disable-line:exported
|
||||
EveryoneAccessMode perm.AccessMode `xorm:"NOT NULL DEFAULT 0"`
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
package v1_22
|
||||
|
||||
import "xorm.io/xorm"
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func DropWronglyCreatedTable(x *xorm.Engine) error {
|
||||
func DropWronglyCreatedTable(x db.EngineMigration) error {
|
||||
return x.DropTables("o_auth2_application")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user