Browse Source

#fix-244

tags/v1.21.12.1
ychao_1983 4 years ago
parent
commit
8e4160840d
1 changed files with 36 additions and 0 deletions
  1. +36
    -0
      models/custom_migrations.go

+ 36
- 0
models/custom_migrations.go View File

@@ -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
}

Loading…
Cancel
Save