Skip to content

Commit cf9d471

Browse files
lunnyzeripath
andauthored
Change topic name size from 25 to 50 (#14150)
* Change topic name size from 25 to 50 * recreateTable requires full bean definition Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent 236e70f commit cf9d471

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

models/migrations/migrations.go

+2
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ var migrations = []Migration{
269269
NewMigration("Convert task type from int to string", convertTaskTypeToString),
270270
// v162 -> v163
271271
NewMigration("Convert webhook task type from int to string", convertWebhookTaskTypeToString),
272+
// v163 -> v164
273+
NewMigration("Convert topic name from 25 to 50", convertTopicNameFrom25To50),
272274
}
273275

274276
// GetCurrentDBVersion returns the current db version

models/migrations/v163.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"xorm.io/xorm"
9+
)
10+
11+
func convertTopicNameFrom25To50(x *xorm.Engine) error {
12+
type Topic struct {
13+
ID int64 `xorm:"pk autoincr"`
14+
Name string `xorm:"UNIQUE VARCHAR(50)"`
15+
RepoCount int
16+
CreatedUnix int64 `xorm:"INDEX created"`
17+
UpdatedUnix int64 `xorm:"INDEX updated"`
18+
}
19+
20+
if err := x.Sync2(new(Topic)); err != nil {
21+
return err
22+
}
23+
24+
sess := x.NewSession()
25+
defer sess.Close()
26+
if err := sess.Begin(); err != nil {
27+
return err
28+
}
29+
if err := recreateTable(sess, new(Topic)); err != nil {
30+
return err
31+
}
32+
33+
return sess.Commit()
34+
}

models/topic.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var topicPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]*$`)
2626
// Topic represents a topic of repositories
2727
type Topic struct {
2828
ID int64 `xorm:"pk autoincr"`
29-
Name string `xorm:"UNIQUE VARCHAR(25)"`
29+
Name string `xorm:"UNIQUE VARCHAR(50)"`
3030
RepoCount int
3131
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
3232
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

0 commit comments

Comments
 (0)