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 (
6868// used in template render.
6969type Action struct {
7070 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.
7272 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.
7474 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) "`
7676 Repo * repo_model.Repository `xorm:"-"`
7777 CommentID int64 `xorm:"INDEX"`
7878 Comment * Comment `xorm:"-"`
79- IsDeleted bool `xorm:"INDEX NOT NULL DEFAULT false"`
79+ IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
8080 RefName string
81- IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
81+ IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
8282 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"`
8484}
8585
8686func init () {
Original file line number Diff line number Diff line change @@ -380,6 +380,8 @@ var migrations = []Migration{
380380 NewMigration ("Create ForeignReference table" , createForeignReferenceTable ),
381381 // v212 -> v213
382382 NewMigration ("Add package tables" , addPackageTables ),
383+ // v213 -> v214
384+ NewMigration ("Improve Action table indices" , improveActionTableIndices ),
383385}
384386
385387// 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