| 
 | 1 | +// Copyright 2024 The Gitea Authors. All rights reserved.  | 
 | 2 | +// SPDX-License-Identifier: MIT  | 
 | 3 | + | 
 | 4 | +package v1_23 //nolint  | 
 | 5 | + | 
 | 6 | +import (  | 
 | 7 | +	"code.gitea.io/gitea/modules/timeutil"  | 
 | 8 | + | 
 | 9 | +	"xorm.io/xorm"  | 
 | 10 | +	"xorm.io/xorm/schemas"  | 
 | 11 | +)  | 
 | 12 | + | 
 | 13 | +type improveActionTableIndicesAction struct {  | 
 | 14 | +	ID          int64 `xorm:"pk autoincr"`  | 
 | 15 | +	UserID      int64 `xorm:"INDEX"` // Receiver user id.  | 
 | 16 | +	OpType      int  | 
 | 17 | +	ActUserID   int64 // Action user id.  | 
 | 18 | +	RepoID      int64  | 
 | 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:"created"`  | 
 | 25 | +}  | 
 | 26 | + | 
 | 27 | +// TableName sets the name of this table  | 
 | 28 | +func (*improveActionTableIndicesAction) TableName() string {  | 
 | 29 | +	return "action"  | 
 | 30 | +}  | 
 | 31 | + | 
 | 32 | +func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {  | 
 | 33 | +	repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)  | 
 | 34 | +	repoIndex.AddColumn("repo_id", "user_id", "is_deleted")  | 
 | 35 | + | 
 | 36 | +	actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)  | 
 | 37 | +	actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")  | 
 | 38 | + | 
 | 39 | +	cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)  | 
 | 40 | +	cudIndex.AddColumn("created_unix", "user_id", "is_deleted")  | 
 | 41 | + | 
 | 42 | +	cuIndex := schemas.NewIndex("c_u", schemas.IndexType)  | 
 | 43 | +	cuIndex.AddColumn("user_id", "is_deleted")  | 
 | 44 | + | 
 | 45 | +	indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex, cuIndex}  | 
 | 46 | + | 
 | 47 | +	return indices  | 
 | 48 | +}  | 
 | 49 | + | 
 | 50 | +func AddNewIndexForUserDashboard(x *xorm.Engine) error {  | 
 | 51 | +	return x.Sync(new(improveActionTableIndicesAction))  | 
 | 52 | +}  | 
0 commit comments