package models import ( "code.gitea.io/gitea/modules/log" "xorm.io/xorm" ) type CustomMigration struct { Description string Migrate func(*xorm.Engine) error } type CustomMigrationStatic struct { Description string Migrate func(*xorm.Engine, *xorm.Engine) error } var customMigrations []CustomMigration var customMigrationsStatic []CustomMigrationStatic 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 MigrateCustomStatic(x *xorm.Engine, static *xorm.Engine) { for _, m := range customMigrationsStatic { log.Info("Migration: %s", m.Description) if err := m.Migrate(x, static); 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 } func updateIssueFixedRate(x *xorm.Engine, static *xorm.Engine) error { updateSQL := "update repo_statistic set issue_fixed_rate=1.0 where num_issues=0" _, err := static.Exec(updateSQL) return err }