diff options
Diffstat (limited to 'models/migrations')
-rw-r--r-- | models/migrations/migrations.go | 8 | ||||
-rw-r--r-- | models/migrations/v19.go | 2 | ||||
-rw-r--r-- | models/migrations/v22.go | 2 | ||||
-rw-r--r-- | models/migrations/v26.go | 2 | ||||
-rw-r--r-- | models/migrations/v27.go | 2 | ||||
-rw-r--r-- | models/migrations/v33.go | 4 | ||||
-rw-r--r-- | models/migrations/v45.go | 4 | ||||
-rw-r--r-- | models/migrations/v50.go | 4 | ||||
-rw-r--r-- | models/migrations/v67.go | 4 | ||||
-rw-r--r-- | models/migrations/v81.go | 2 |
10 files changed, 15 insertions, 19 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index fc086bfd46..7d97741a20 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -296,7 +296,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin // TODO: This will not work if there are foreign keys switch { - case setting.UseSQLite3: + case setting.Database.UseSQLite3: // First drop the indexes on the columns res, errIndex := sess.Query(fmt.Sprintf("PRAGMA index_list(`%s`)", tableName)) if errIndex != nil { @@ -372,7 +372,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin return err } - case setting.UsePostgreSQL: + case setting.Database.UsePostgreSQL: cols := "" for _, col := range columnNames { if cols != "" { @@ -383,7 +383,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) } - case setting.UseMySQL, setting.UseTiDB: + case setting.Database.UseMySQL: // Drop indexes on columns first sql := fmt.Sprintf("SHOW INDEX FROM %s WHERE column_name IN ('%s')", tableName, strings.Join(columnNames, "','")) res, err := sess.Query(sql) @@ -409,7 +409,7 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin if _, err := sess.Exec(fmt.Sprintf("ALTER TABLE `%s` %s", tableName, cols)); err != nil { return fmt.Errorf("Drop table `%s` columns %v: %v", tableName, columnNames, err) } - case setting.UseMSSQL: + case setting.Database.UseMSSQL: cols := "" for _, col := range columnNames { if cols != "" { diff --git a/models/migrations/v19.go b/models/migrations/v19.go index 9793f405ad..7728f5add6 100644 --- a/models/migrations/v19.go +++ b/models/migrations/v19.go @@ -42,7 +42,7 @@ func generateAndMigrateGitHooks(x *xorm.Engine) (err error) { } ) - return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.Database.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/migrations/v22.go b/models/migrations/v22.go index f991ae25fa..faac74343b 100644 --- a/models/migrations/v22.go +++ b/models/migrations/v22.go @@ -42,7 +42,7 @@ func generateAndMigrateWikiGitHooks(x *xorm.Engine) (err error) { } ) - return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.Database.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/migrations/v26.go b/models/migrations/v26.go index 3d88c62923..04277191f5 100644 --- a/models/migrations/v26.go +++ b/models/migrations/v26.go @@ -36,7 +36,7 @@ func generateAndMigrateGitHookChains(x *xorm.Engine) (err error) { hookTpl = fmt.Sprintf("#!/usr/bin/env %s\ndata=$(cat)\nexitcodes=\"\"\nhookname=$(basename $0)\nGIT_DIR=${GIT_DIR:-$(dirname $0)}\n\nfor hook in ${GIT_DIR}/hooks/${hookname}.d/*; do\ntest -x \"${hook}\" || continue\necho \"${data}\" | \"${hook}\"\nexitcodes=\"${exitcodes} $?\"\ndone\n\nfor i in ${exitcodes}; do\n[ ${i} -eq 0 ] || exit ${i}\ndone\n", setting.ScriptType) ) - return x.Where("id > 0").BufferSize(setting.IterateBufferSize).Iterate(new(Repository), + return x.Where("id > 0").BufferSize(setting.Database.IterateBufferSize).Iterate(new(Repository), func(idx int, bean interface{}) error { repo := bean.(*Repository) user := new(User) diff --git a/models/migrations/v27.go b/models/migrations/v27.go index e87c7ab68f..12e5fbcdbf 100644 --- a/models/migrations/v27.go +++ b/models/migrations/v27.go @@ -41,8 +41,6 @@ func convertIntervalToDuration(x *xorm.Engine) (err error) { _, err = sess.Exec("ALTER TABLE mirror MODIFY `interval` BIGINT") case "postgres": _, err = sess.Exec("ALTER TABLE mirror ALTER COLUMN \"interval\" SET DATA TYPE bigint") - case "tidb": - _, err = sess.Exec("ALTER TABLE mirror MODIFY `interval` BIGINT") case "mssql": _, err = sess.Exec("ALTER TABLE mirror ALTER COLUMN \"interval\" BIGINT") case "sqlite3": diff --git a/models/migrations/v33.go b/models/migrations/v33.go index ae7612e68c..566951db96 100644 --- a/models/migrations/v33.go +++ b/models/migrations/v33.go @@ -15,9 +15,9 @@ import ( func removeActionColumns(x *xorm.Engine) error { switch { - case setting.UseSQLite3: + case setting.Database.UseSQLite3: log.Warn("Unable to drop columns in SQLite") - case setting.UseMySQL, setting.UsePostgreSQL, setting.UseMSSQL, setting.UseTiDB: + case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL: if _, err := x.Exec("ALTER TABLE action DROP COLUMN act_user_name"); err != nil { return fmt.Errorf("DROP COLUMN act_user_name: %v", err) } else if _, err = x.Exec("ALTER TABLE action DROP COLUMN repo_user_name"); err != nil { diff --git a/models/migrations/v45.go b/models/migrations/v45.go index 92cb817819..99baff2c8b 100644 --- a/models/migrations/v45.go +++ b/models/migrations/v45.go @@ -13,9 +13,9 @@ import ( func removeIndexColumnFromRepoUnitTable(x *xorm.Engine) (err error) { switch { - case setting.UseSQLite3: + case setting.Database.UseSQLite3: log.Warn("Unable to drop columns in SQLite") - case setting.UseMySQL, setting.UsePostgreSQL, setting.UseMSSQL, setting.UseTiDB: + case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL: if _, err := x.Exec("ALTER TABLE repo_unit DROP COLUMN `index`"); err != nil { // Ignoring this error in case we run this migration second time (after migration reordering) log.Warn("DROP COLUMN index: %v", err) diff --git a/models/migrations/v50.go b/models/migrations/v50.go index a15914f0ee..23b1bb526e 100644 --- a/models/migrations/v50.go +++ b/models/migrations/v50.go @@ -40,9 +40,9 @@ func migrateProtectedBranchStruct(x *xorm.Engine) error { } switch { - case setting.UseSQLite3: + case setting.Database.UseSQLite3: log.Warn("Unable to drop columns in SQLite") - case setting.UseMySQL, setting.UsePostgreSQL, setting.UseMSSQL, setting.UseTiDB: + case setting.Database.UseMySQL, setting.Database.UsePostgreSQL, setting.Database.UseMSSQL: if _, err := x.Exec("ALTER TABLE protected_branch DROP COLUMN can_push"); err != nil { // Ignoring this error in case we run this migration second time (after migration reordering) log.Warn("DROP COLUMN can_push (skipping): %v", err) diff --git a/models/migrations/v67.go b/models/migrations/v67.go index 74d3f379cd..6cf3dd4d19 100644 --- a/models/migrations/v67.go +++ b/models/migrations/v67.go @@ -80,7 +80,7 @@ func removeStaleWatches(x *xorm.Engine) error { } repoCache := make(map[int64]*Repository) - err := sess.BufferSize(setting.IterateBufferSize).Iterate(new(Watch), + err := sess.BufferSize(setting.Database.IterateBufferSize).Iterate(new(Watch), func(idx int, bean interface{}) error { watch := bean.(*Watch) @@ -117,7 +117,7 @@ func removeStaleWatches(x *xorm.Engine) error { } repoCache = make(map[int64]*Repository) - err = sess.BufferSize(setting.IterateBufferSize). + err = sess.BufferSize(setting.Database.IterateBufferSize). Distinct("issue_watch.user_id", "issue.repo_id"). Join("INNER", "issue", "issue_watch.issue_id = issue.id"). Where("issue_watch.is_watching = ?", true). diff --git a/models/migrations/v81.go b/models/migrations/v81.go index 56bb8477e6..48e96508d9 100644 --- a/models/migrations/v81.go +++ b/models/migrations/v81.go @@ -14,8 +14,6 @@ func changeU2FCounterType(x *xorm.Engine) error { var err error switch x.Dialect().DriverName() { - case "tidb": - fallthrough case "mysql": _, err = x.Exec("ALTER TABLE `u2f_registration` MODIFY `counter` BIGINT") case "postgres": |