Skip to content

Commit bed6120

Browse files
committed
remove unsupported tidb options
1 parent 292a68a commit bed6120

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

models/migrations/migrations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin
383383
if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil {
384384
return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err)
385385
}
386-
case setting.Database.UseMySQL, setting.Database.UseTiDB:
386+
case setting.Database.UseMySQL:
387387
// Drop indexes on columns first
388388
sql := fmt.Sprintf("SHOW INDEX FROM %s WHERE column_name IN ('%s')", tableName, strings.Join(columnNames, "','"))
389389
res, err := sess.Query(sql)

models/migrations/v33.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func removeActionColumns(x *xorm.Engine) error {
1717
switch {
1818
case setting.Database.UseSQLite3:
1919
log.Warn("Unable to drop columns in SQLite")
20-
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL, setting.Database.UseTiDB:
20+
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL:
2121
if _, err := x.Exec("ALTER TABLE action DROP COLUMN act_user_name"); err != nil {
2222
return fmt.Errorf("DROP COLUMN act_user_name: %v", err)
2323
} else if _, err = x.Exec("ALTER TABLE action DROP COLUMN repo_user_name"); err != nil {

models/migrations/v45.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func removeIndexColumnFromRepoUnitTable(x *xorm.Engine) (err error) {
1515
switch {
1616
case setting.Database.UseSQLite3:
1717
log.Warn("Unable to drop columns in SQLite")
18-
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL, setting.Database.UseTiDB:
18+
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL:
1919
if _, err := x.Exec("ALTER TABLE repo_unit DROP COLUMN `index`"); err != nil {
2020
// Ignoring this error in case we run this migration second time (after migration reordering)
2121
log.Warn("DROP COLUMN index: %v", err)

models/migrations/v50.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func migrateProtectedBranchStruct(x *xorm.Engine) error {
4242
switch {
4343
case setting.Database.UseSQLite3:
4444
log.Warn("Unable to drop columns in SQLite")
45-
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL, setting.Database.UseTiDB:
45+
case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL:
4646
if _, err := x.Exec("ALTER TABLE protected_branch DROP COLUMN can_push"); err != nil {
4747
// Ignoring this error in case we run this migration second time (after migration reordering)
4848
log.Warn("DROP COLUMN can_push (skipping): %v", err)

models/models_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func TestDumpDatabase(t *testing.T) {
2222
assert.NoError(t, err)
2323

2424
for _, dbType := range setting.SupportedDatabases {
25+
dbType = setting.GetDBTypeByName(dbType)
2526
assert.NoError(t, DumpDatabase(filepath.Join(dir, dbType+".sql"), dbType))
2627
}
2728
}

modules/setting/database.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717

1818
var (
1919
// SupportedDatabases includes all supported databases type
20-
SupportedDatabases = []string{"mysql", "postgres", "mssql"}
20+
SupportedDatabases = []string{"MySQL", "PostgreSQL", "MSSQL"}
21+
dbTypes = map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "MSSQL": "mssql", "SQLite3": "sqlite3"}
2122

2223
// EnableSQLite3 use SQLite3, set by build flag
2324
EnableSQLite3 bool
@@ -41,7 +42,6 @@ var (
4142
UseMySQL bool
4243
UseMSSQL bool
4344
UsePostgreSQL bool
44-
UseTiDB bool
4545
DBConnectRetries int
4646
DBConnectBackoff time.Duration
4747
MaxIdleConns int
@@ -54,6 +54,11 @@ var (
5454
}
5555
)
5656

57+
// GetDBTypeByName returns the dataase type as it defined on XORM according the given name
58+
func GetDBTypeByName(name string) string {
59+
return dbTypes[name]
60+
}
61+
5762
// InitDBConfig loads the database settings
5863
func InitDBConfig() {
5964
sec := Cfg.Section("database")
@@ -65,8 +70,6 @@ func InitDBConfig() {
6570
Database.UseMySQL = true
6671
case "postgres":
6772
Database.UsePostgreSQL = true
68-
case "tidb":
69-
Database.UseTiDB = true
7073
case "mssql":
7174
Database.UseMSSQL = true
7275
}

modules/setting/database_sqlite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import (
1212

1313
func init() {
1414
EnableSQLite3 = true
15-
SupportedDatabases = append(SupportedDatabases, "sqlite3")
15+
SupportedDatabases = append(SupportedDatabases, "SQLite3")
1616
}

routers/install.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ func InstallInit(ctx *context.Context) {
4040
ctx.Data["Title"] = ctx.Tr("install.install")
4141
ctx.Data["PageIsInstall"] = true
4242

43-
dbOpts := []string{"MySQL", "PostgreSQL", "MSSQL"}
44-
if setting.EnableSQLite3 {
45-
dbOpts = append(dbOpts, "SQLite3")
46-
}
47-
ctx.Data["DbOptions"] = dbOpts
43+
ctx.Data["DbOptions"] = setting.SupportedDatabases
4844
}
4945

5046
// Install render installation page
@@ -144,8 +140,8 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
144140

145141
// Pass basic check, now test configuration.
146142
// Test database setting.
147-
dbTypes := map[string]string{"MySQL": "mysql", "PostgreSQL": "postgres", "MSSQL": "mssql", "SQLite3": "sqlite3"}
148-
setting.Database.Type = dbTypes[form.DbType]
143+
144+
setting.Database.Type = setting.GetDBTypeByName(form.DbType)
149145
setting.Database.Host = form.DbHost
150146
setting.Database.User = form.DbUser
151147
setting.Database.Passwd = form.DbPasswd

0 commit comments

Comments
 (0)