You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

custom_migrations.go 646 B

3 years ago
123456789101112131415161718192021222324252627282930313233343536
  1. package models
  2. import (
  3. "code.gitea.io/gitea/modules/log"
  4. "xorm.io/xorm"
  5. )
  6. type CustomMigration struct {
  7. Description string
  8. Migrate func(*xorm.Engine) error
  9. }
  10. var customMigrations = []CustomMigration{
  11. {"Custom v1 Topic struct change to support chinese", syncTopicStruct},
  12. }
  13. func MigrateCustom(x *xorm.Engine) {
  14. for _, m := range customMigrations {
  15. log.Info("Migration: %s", m.Description)
  16. if err := m.Migrate(x); err != nil {
  17. log.Error("Migration: %v", err)
  18. }
  19. }
  20. }
  21. func syncTopicStruct(x *xorm.Engine) error {
  22. query := "ALTER TABLE topic ALTER COLUMN name TYPE varchar(105);"
  23. _, err := x.Exec(query)
  24. return err
  25. }