Skip to content

Commit 789ea00

Browse files
committed
add migration
1 parent c20f43e commit 789ea00

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ var migrations = []Migration{
236236
NewMigration("add original author/url migration info to issues, comments, and repo ", addOriginalMigrationInfo),
237237
// v90 -> v91
238238
NewMigration("change length of some repository columns", changeSomeColumnsLengthOfRepo),
239+
// v91 -> v92
240+
NewMigration("add index on owner_id of repository and type, review_id of comment", addIndexOnRepositoryAndComment),
239241
}
240242

241243
// Migrate database to current version

models/migrations/v91.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2019 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 "github.com/go-xorm/xorm"
8+
9+
func addIndexOnRepositoryAndComment(x *xorm.Engine) error {
10+
type Repository struct {
11+
ID int64 `xorm:"pk autoincr"`
12+
OwnerID int64 `xorm:"index"`
13+
}
14+
15+
if err := x.Sync2(new(Repository)); err != nil {
16+
return err
17+
}
18+
19+
type Comment struct {
20+
ID int64 `xorm:"pk autoincr"`
21+
Type int `xorm:"index"`
22+
ReviewID int64 `xorm:"index"`
23+
}
24+
25+
return x.Sync2(new(Comment))
26+
}

0 commit comments

Comments
 (0)