File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -68,19 +68,19 @@ const (
68
68
// used in template render.
69
69
type Action struct {
70
70
ID int64 `xorm:"pk autoincr"`
71
- UserID int64 `xorm:"INDEX"` // Receiver user id.
71
+ UserID int64 `xorm:"INDEX(u_ua_and_r) "` // Receiver user id.
72
72
OpType ActionType
73
- ActUserID int64 `xorm:"INDEX"` // Action user id.
73
+ ActUserID int64 `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r) "` // Action user id.
74
74
ActUser * user_model.User `xorm:"-"`
75
- RepoID int64 `xorm:"INDEX"`
75
+ RepoID int64 `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r) INDEX(r) "`
76
76
Repo * repo_model.Repository `xorm:"-"`
77
77
CommentID int64 `xorm:"INDEX"`
78
78
Comment * Comment `xorm:"-"`
79
- IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"`
79
+ IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
80
80
RefName string
81
- IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
81
+ IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
82
82
Content string `xorm:"TEXT"`
83
- CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
83
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r) INDEX(r) created"`
84
84
}
85
85
86
86
func init () {
Original file line number Diff line number Diff line change @@ -380,6 +380,8 @@ var migrations = []Migration{
380
380
NewMigration ("Create ForeignReference table" , createForeignReferenceTable ),
381
381
// v212 -> v213
382
382
NewMigration ("Add package tables" , addPackageTables ),
383
+ // v213 -> v214
384
+ NewMigration ("Improve Action table indices" , improveActionTableIndices ),
383
385
}
384
386
385
387
// GetCurrentDBVersion returns the current db version
Original file line number Diff line number Diff line change
1
+ // Copyright 2022 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
+ "code.gitea.io/gitea/modules/timeutil"
9
+ "xorm.io/xorm"
10
+ )
11
+
12
+ func improveActionTableIndices (x * xorm.Engine ) error {
13
+ type Action struct {
14
+ ID int64 `xorm:"pk autoincr"`
15
+ UserID int64 `xorm:"INDEX(u_ua_and_r)"` // Receiver user id.
16
+ OpType int
17
+ ActUserID int64 `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r)"` // Action user id.
18
+ RepoID int64 `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r) INDEX(r)"`
19
+ CommentID int64 `xorm:"INDEX"`
20
+ IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
21
+ RefName string
22
+ IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
23
+ Content string `xorm:"TEXT"`
24
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX(u_ua_and_r) INDEX(ua_and_r) INDEX(r) created"`
25
+ }
26
+ return x .Sync2 (& Action {})
27
+ }
You can’t perform that action at this time.
0 commit comments