Skip to content

Commit

Permalink
add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Aug 4, 2019
1 parent c20f43e commit 789ea00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ var migrations = []Migration{
NewMigration("add original author/url migration info to issues, comments, and repo ", addOriginalMigrationInfo),
// v90 -> v91
NewMigration("change length of some repository columns", changeSomeColumnsLengthOfRepo),
// v91 -> v92
NewMigration("add index on owner_id of repository and type, review_id of comment", addIndexOnRepositoryAndComment),
}

// Migrate database to current version
Expand Down
26 changes: 26 additions & 0 deletions models/migrations/v91.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import "github.com/go-xorm/xorm"

func addIndexOnRepositoryAndComment(x *xorm.Engine) error {
type Repository struct {
ID int64 `xorm:"pk autoincr"`
OwnerID int64 `xorm:"index"`
}

if err := x.Sync2(new(Repository)); err != nil {
return err
}

type Comment struct {
ID int64 `xorm:"pk autoincr"`
Type int `xorm:"index"`
ReviewID int64 `xorm:"index"`
}

return x.Sync2(new(Comment))
}

0 comments on commit 789ea00

Please sign in to comment.