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 20, 2024
commit 99fef44280ff8c00b8efc274e8fbca9a0d464344
7 changes: 0 additions & 7 deletions models/auth/oauth2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ import (
"github.com/stretchr/testify/assert"
)

func TestApplicationTableName(t *testing.T) {
e := unittest.GetXORMEngine()
tableInfo, err := e.TableInfo(new(auth_model.OAuth2Application))
assert.NoError(t, err)
assert.EqualValues(t, "oauth2_application", tableInfo.Name)
}

func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
Expand Down
16 changes: 10 additions & 6 deletions models/migrations/v1_18/v230.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ 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 {
type OAuth2Application struct {
ID int64
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
}

return x.Table("oauth2_application").Sync(new(OAuth2Application))
return x.Sync(new(oAuth2Application))
lunny marked this conversation as resolved.
Show resolved Hide resolved
}