From ff8ced8b03eedecae09c25d7005b57b98d781827 Mon Sep 17 00:00:00 2001 From: FingerLeader Date: Wed, 9 Oct 2024 15:26:46 +0800 Subject: [PATCH] test1 Signed-off-by: FingerLeader --- db.go | 11 ++++++- go.mod | 85 ++++++++++++++++++++++++++++++++++++++++++++------- main_test.go | 2 +- models.go | 1 + tidbcloud.yml | 2 +- 5 files changed, 87 insertions(+), 14 deletions(-) diff --git a/db.go b/db.go index 359d718..c1b3a11 100644 --- a/db.go +++ b/db.go @@ -115,7 +115,16 @@ func RunMigrations() { return err } return nil - }, + }, + }, { + // alter table + ID: "202307111200", + Migrate: func(db *gorm.DB) error { + if err := db.Exec("ALTER TABLE `users` ADD `new_wrong_field` varchar(255) NOT NULL").Error; err != nil { + return err + } + return nil + }, }}) if err = m.Migrate(); err != nil { diff --git a/go.mod b/go.mod index 4d5943a..a592054 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,81 @@ module gorm.io/playground -go 1.16 +go 1.21 + +toolchain go1.22.0 + +require ( + github.com/go-gormigrate/gormigrate/v2 v2.1.3 + github.com/go-sql-driver/mysql v1.8.1 + gorm.io/driver/mysql v1.5.7 + gorm.io/driver/postgres v1.5.9 + gorm.io/driver/sqlite v1.5.6 + gorm.io/driver/sqlserver v1.5.3 + gorm.io/gorm v1.25.12 +) require ( - github.com/go-gormigrate/gormigrate/v2 v2.1.0 - github.com/go-sql-driver/mysql v1.7.1 - github.com/jackc/pgx/v5 v5.4.3 // indirect - github.com/microsoft/go-mssqldb v1.6.0 // indirect - golang.org/x/crypto v0.13.0 // indirect - gorm.io/driver/mysql v1.5.1 - gorm.io/driver/postgres v1.5.2 - gorm.io/driver/sqlite v1.5.3 - gorm.io/driver/sqlserver v1.5.1 - gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 + filippo.io/edwards25519 v1.1.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect + github.com/creack/pty v1.1.9 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dnaeon/go-vcr v1.2.0 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect + github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect + github.com/golang-sql/sqlexp v0.1.0 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorilla/securecookie v1.1.1 // indirect + github.com/gorilla/sessions v1.2.1 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect + github.com/jackc/pgx/v5 v5.7.1 // indirect + github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/jcmturner/aescts/v2 v2.0.0 // indirect + github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect + github.com/jcmturner/gofork v1.7.6 // indirect + github.com/jcmturner/goidentity/v6 v6.0.1 // indirect + github.com/jcmturner/gokrb5/v8 v8.4.4 // indirect + github.com/jcmturner/rpc/v2 v2.0.3 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/joho/godotenv v1.5.1 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/kr/pty v1.1.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/mattn/go-sqlite3 v1.14.24 // indirect + github.com/microsoft/go-mssqldb v1.7.2 // indirect + github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5 // indirect + github.com/montanaflynn/stats v0.7.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/testify v1.8.4 // indirect + github.com/yuin/goldmark v1.4.13 // indirect + golang.org/x/crypto v0.28.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.26.0 // indirect + golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 // indirect + golang.org/x/term v0.25.0 // indirect + golang.org/x/text v0.19.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/errgo.v2 v2.1.0 // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) replace gorm.io/gorm => ./gorm diff --git a/main_test.go b/main_test.go index bb498d3..edbb822 100644 --- a/main_test.go +++ b/main_test.go @@ -9,7 +9,7 @@ import ( // TEST_DRIVERS: sqlite, mysql, postgres, sqlserver, tidb func TestGORM(t *testing.T) { - user := User{Name: "jinzhu"} + user := User{Name: "jinzhu", NewField: "new_field"} DB.Create(&user) diff --git a/models.go b/models.go index 692a684..ec7dfb5 100644 --- a/models.go +++ b/models.go @@ -27,6 +27,7 @@ type User struct { Languages []Language `gorm:"many2many:UserSpeak"` Friends []*User `gorm:"many2many:user_friends"` Active bool + NewField string } type Account struct { diff --git a/tidbcloud.yml b/tidbcloud.yml index f9338cc..00852ef 100644 --- a/tidbcloud.yml +++ b/tidbcloud.yml @@ -1,4 +1,4 @@ github: branch: allowList: - - "ci_example" + - "column_typo_example"