Skip to content

Commit c81b9fe

Browse files
JakobDevGiteaBot
andcommitted
Add Index to action.user_id (go-gitea#27403)
Another Column that needs a Index. Found at https://codeberg.org/forgejo/discussions/issues/61#issuecomment-1258744. Co-authored-by: Giteabot <[email protected]>
1 parent 881a844 commit c81b9fe

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

models/activities/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (at ActionType) InActions(actions ...string) bool {
140140
// used in template render.
141141
type Action struct {
142142
ID int64 `xorm:"pk autoincr"`
143-
UserID int64 // Receiver user id.
143+
UserID int64 `xorm:"INDEX"` // Receiver user id.
144144
OpType ActionType
145145
ActUserID int64 // Action user id.
146146
ActUser *user_model.User `xorm:"-"`

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,8 @@ var migrations = []Migration{
538538
NewMigration("Add Index to issue_user.issue_id", v1_21.AddIndexToIssueUserIssueID),
539539
// v278 -> v279
540540
NewMigration("Add Index to comment.dependent_issue_id", v1_21.AddIndexToCommentDependentIssueID),
541+
// v279 -> v280
542+
NewMigration("Add Index to action.user_id", v1_21.AddIndexToActionUserID),
541543
}
542544

543545
// GetCurrentDBVersion returns the current db version

models/migrations/v1_21/v279.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_21 //nolint
5+
6+
import (
7+
"xorm.io/xorm"
8+
)
9+
10+
func AddIndexToActionUserID(x *xorm.Engine) error {
11+
type Action struct {
12+
UserID int64 `xorm:"INDEX"`
13+
}
14+
15+
return x.Sync(new(Action))
16+
}

0 commit comments

Comments
 (0)