This commit is contained in:
@@ -6,9 +6,9 @@ package v1_17
|
||||
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,10 +3,8 @@
|
||||
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func CreateForeignReferenceTable(_ *xorm.Engine) error {
|
||||
func CreateForeignReferenceTable(_ db.EngineMigration) error {
|
||||
return nil // This table was dropped in v1_19/v237.go
|
||||
}
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func AddPackageTables(x *xorm.Engine) error {
|
||||
func AddPackageTables(x db.EngineMigration) error {
|
||||
type Package struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
OwnerID int64 `xorm:"UNIQUE(s) INDEX NOT NULL"`
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func AddAllowMaintainerEdit(x *xorm.Engine) error {
|
||||
func AddAllowMaintainerEdit(x db.EngineMigration) error {
|
||||
// PullRequest represents relation between pull request and repositories.
|
||||
type PullRequest struct {
|
||||
AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"`
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
import "gitea.dev/models/db"
|
||||
|
||||
func AddAutoMergeTable(x *xorm.Engine) error {
|
||||
func AddAutoMergeTable(x db.EngineMigration) error {
|
||||
type MergeStyle string
|
||||
type PullAutoMerge struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
|
||||
@@ -4,13 +4,12 @@
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/models/pull"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/pull"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func AddReviewViewedFiles(x *xorm.Engine) error {
|
||||
func AddReviewViewedFiles(x db.EngineMigration) error {
|
||||
type ReviewState struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
UserID int64 `xorm:"NOT NULL UNIQUE(pull_commit_user)"`
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/setting"
|
||||
)
|
||||
|
||||
func AlterHookTaskTextFieldsToLongText(x *xorm.Engine) error {
|
||||
func AlterHookTaskTextFieldsToLongText(x db.EngineMigration) error {
|
||||
sess := x.NewSession()
|
||||
defer sess.Close()
|
||||
if err := sess.Begin(); err != nil {
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
@@ -47,6 +47,6 @@ func (*improveActionTableIndicesAction) TableIndices() []*schemas.Index {
|
||||
return indices
|
||||
}
|
||||
|
||||
func ImproveActionTableIndices(x *xorm.Engine) error {
|
||||
func ImproveActionTableIndices(x db.EngineMigration) error {
|
||||
return x.Sync(&improveActionTableIndicesAction{})
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ package v1_17
|
||||
import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/repo"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/repo"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func AddSyncOnCommitColForPushMirror(x *xorm.Engine) error {
|
||||
func AddSyncOnCommitColForPushMirror(x db.EngineMigration) error {
|
||||
type PushMirror struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
RepoID int64 `xorm:"INDEX"`
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
package v1_17
|
||||
|
||||
import (
|
||||
packages_model "code.gitea.io/gitea/models/packages"
|
||||
container_module "code.gitea.io/gitea/modules/packages/container"
|
||||
"gitea.dev/models/db"
|
||||
packages_model "gitea.dev/models/packages"
|
||||
container_module "gitea.dev/modules/packages/container"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"xorm.io/xorm/schemas"
|
||||
)
|
||||
|
||||
func AddContainerRepositoryProperty(x *xorm.Engine) (err error) {
|
||||
func AddContainerRepositoryProperty(x db.EngineMigration) (err error) {
|
||||
switch x.Dialect().URI().DBType {
|
||||
case schemas.SQLITE:
|
||||
_, err = x.Exec("INSERT INTO package_property (ref_type, ref_id, name, value) SELECT ?, p.id, ?, u.lower_name || '/' || p.lower_name FROM package p JOIN `user` u ON p.owner_id = u.id WHERE p.type = ?",
|
||||
|
||||
@@ -7,12 +7,11 @@ import (
|
||||
"encoding/base32"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func StoreWebauthnCredentialIDAsBytes(x *xorm.Engine) error {
|
||||
func StoreWebauthnCredentialIDAsBytes(x db.EngineMigration) error {
|
||||
// Create webauthnCredential table
|
||||
type webauthnCredential struct {
|
||||
ID int64 `xorm:"pk autoincr"`
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/base32"
|
||||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"gitea.dev/models/migrations/migrationtest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -38,7 +38,7 @@ func Test_StoreWebauthnCredentialIDAsBytes(t *testing.T) {
|
||||
}
|
||||
|
||||
// Prepare and load the testing database
|
||||
x, deferable := base.PrepareTestEnv(t, 0, new(WebauthnCredential), new(ExpectedWebauthnCredential))
|
||||
x, deferable := migrationtest.PrepareTestEnv(t, 0, new(WebauthnCredential), new(ExpectedWebauthnCredential))
|
||||
defer deferable()
|
||||
if x == nil || t.Failed() {
|
||||
return
|
||||
|
||||
@@ -8,13 +8,12 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/migrations/base"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func DropOldCredentialIDColumn(x *xorm.Engine) error {
|
||||
func DropOldCredentialIDColumn(x db.EngineMigration) error {
|
||||
// This migration maybe rerun so that we should check if it has been run
|
||||
credentialIDExist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "webauthn_credential", "credential_id")
|
||||
if err != nil {
|
||||
|
||||
@@ -7,14 +7,13 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/gitea/models/migrations/base"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
||||
"xorm.io/xorm"
|
||||
"gitea.dev/models/db"
|
||||
"gitea.dev/models/migrations/base"
|
||||
"gitea.dev/modules/setting"
|
||||
"gitea.dev/modules/timeutil"
|
||||
)
|
||||
|
||||
func RenameCredentialIDBytes(x *xorm.Engine) error {
|
||||
func RenameCredentialIDBytes(x db.EngineMigration) error {
|
||||
// This migration maybe rerun so that we should check if it has been run
|
||||
credentialIDExist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "webauthn_credential", "credential_id")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user