| @@ -0,0 +1,36 @@ | |||||
| package models | |||||
| import ( | |||||
| "code.gitea.io/gitea/modules/log" | |||||
| "xorm.io/xorm" | |||||
| ) | |||||
| type CustomMigration struct { | |||||
| Description string | |||||
| Migrate func(*xorm.Engine) error | |||||
| } | |||||
| var customMigrations = []CustomMigration{ | |||||
| {"Custom v1 Topic struct change to support chinese", syncTopicStruct}, | |||||
| } | |||||
| func MigrateCustom(x *xorm.Engine) { | |||||
| for _, m := range customMigrations { | |||||
| log.Info("Migration: %s", m.Description) | |||||
| if err := m.Migrate(x); err != nil { | |||||
| log.Error("Migration: %v", err) | |||||
| } | |||||
| } | |||||
| } | |||||
| func syncTopicStruct(x *xorm.Engine) error { | |||||
| query := "ALTER TABLE topic ALTER COLUMN name TYPE varchar(105);" | |||||
| _, err := x.Exec(query) | |||||
| return err | |||||
| } | |||||