2020-12-27 04:58:47 +05:30
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2020-12-27 04:58:47 +05:30
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
package v1_14 //nolint
|
2020-12-27 04:58:47 +05:30
|
|
|
|
|
|
|
import (
|
2022-11-02 14:24:36 +05:30
|
|
|
"code.gitea.io/gitea/models/migrations/base"
|
|
|
|
|
2020-12-27 04:58:47 +05:30
|
|
|
"xorm.io/xorm"
|
|
|
|
)
|
|
|
|
|
2022-11-02 14:24:36 +05:30
|
|
|
func ConvertTopicNameFrom25To50(x *xorm.Engine) error {
|
2020-12-27 04:58:47 +05:30
|
|
|
type Topic struct {
|
|
|
|
ID int64 `xorm:"pk autoincr"`
|
|
|
|
Name string `xorm:"UNIQUE VARCHAR(50)"`
|
|
|
|
RepoCount int
|
|
|
|
CreatedUnix int64 `xorm:"INDEX created"`
|
|
|
|
UpdatedUnix int64 `xorm:"INDEX updated"`
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := x.Sync2(new(Topic)); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
sess := x.NewSession()
|
|
|
|
defer sess.Close()
|
|
|
|
if err := sess.Begin(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-11-02 14:24:36 +05:30
|
|
|
if err := base.RecreateTable(sess, new(Topic)); err != nil {
|
2020-12-27 04:58:47 +05:30
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return sess.Commit()
|
|
|
|
}
|