Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong table name #30557

Merged
merged 15 commits into from
Apr 23, 2024
Prev Previous commit
Next Next commit
Follow wxiaoguang's suggestion
  • Loading branch information
lunny committed Apr 22, 2024
commit c073714c387919927b9f0ea1538e8c1b0ec55c0e
15 changes: 5 additions & 10 deletions models/migrations/v1_18/v230.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ import (
"xorm.io/xorm"
)

type oAuth2Application struct {
ID int64
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
}

func (oAuth2Application) TableName() string {
return "oauth2_application"
}

// AddConfidentialColumnToOAuth2ApplicationTable: add ConfidentialClient column, setting existing rows to true
func AddConfidentialClientColumnToOAuth2ApplicationTable(x *xorm.Engine) error {
return x.Sync(new(oAuth2Application))
type oauth2Application struct {
ID int64
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
}
return x.Sync(new(oauth2Application))
}
16 changes: 6 additions & 10 deletions models/migrations/v1_18/v230_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ import (
"github.com/stretchr/testify/assert"
)

// premigration
type OAuth2Application struct {
ID int64
}

func (OAuth2Application) TableName() string {
return "oauth2_application"
}

func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
// premigration
type oauth2Application struct {
ID int64
}

// Prepare and load the testing database
x, deferable := base.PrepareTestEnv(t, 0, new(OAuth2Application))
x, deferable := base.PrepareTestEnv(t, 0, new(oAuth2Application))
defer deferable()
if x == nil || t.Failed() {
return
Expand Down