Skip to content

Commit e94864e

Browse files
authored
Fix wrong table name (#30557)
The table name should be `oauth2_application` but `o_auth2_application` Caused by https://github.com/go-gitea/gitea/pull/21316/files#diff-9610efbc608a41f1f2eaff5790423f0a187906f6ff0beb23a5e8d18366cc2ccfR38
1 parent 8924d9b commit e94864e

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

models/auth/oauth2_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"github.com/stretchr/testify/assert"
1414
)
1515

16-
//////////////////// Application
17-
1816
func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
1917
assert.NoError(t, unittest.PrepareTestDatabase())
2018
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ var migrations = []Migration{
584584
NewMigration("Add missing field of commit status summary table", v1_23.AddCommitStatusSummary2),
585585
// v297 -> v298
586586
NewMigration("Add everyone_access_mode for repo_unit", v1_23.AddRepoUnitEveryoneAccessMode),
587+
// v298 -> v299
588+
NewMigration("Drop wrongly created table o_auth2_application", v1_23.DropWronglyCreatedTable),
587589
}
588590

589591
// GetCurrentDBVersion returns the current db version

models/migrations/v1_18/v230.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99

1010
// AddConfidentialColumnToOAuth2ApplicationTable: add ConfidentialClient column, setting existing rows to true
1111
func AddConfidentialClientColumnToOAuth2ApplicationTable(x *xorm.Engine) error {
12-
type OAuth2Application struct {
12+
type oauth2Application struct {
13+
ID int64
1314
ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
1415
}
15-
16-
return x.Sync(new(OAuth2Application))
16+
return x.Sync(new(oauth2Application))
1717
}

models/migrations/v1_18/v230_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import (
1313

1414
func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
1515
// premigration
16-
type OAuth2Application struct {
16+
type oauth2Application struct {
1717
ID int64
1818
}
1919

2020
// Prepare and load the testing database
21-
x, deferable := base.PrepareTestEnv(t, 0, new(OAuth2Application))
21+
x, deferable := base.PrepareTestEnv(t, 0, new(oauth2Application))
2222
defer deferable()
2323
if x == nil || t.Failed() {
2424
return
@@ -36,7 +36,7 @@ func Test_AddConfidentialClientColumnToOAuth2ApplicationTable(t *testing.T) {
3636
}
3737

3838
got := []ExpectedOAuth2Application{}
39-
if err := x.Table("o_auth2_application").Select("id, confidential_client").Find(&got); !assert.NoError(t, err) {
39+
if err := x.Table("oauth2_application").Select("id, confidential_client").Find(&got); !assert.NoError(t, err) {
4040
return
4141
}
4242

models/migrations/v1_23/v298.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_23 //nolint
5+
6+
import "xorm.io/xorm"
7+
8+
func DropWronglyCreatedTable(x *xorm.Engine) error {
9+
return x.DropTables("o_auth2_application")
10+
}

0 commit comments

Comments
 (0)