|
| 1 | +// Copyright 2025 The Gitea Authors. All rights reserved. |
| 2 | +// SPDX-License-Identifier: MIT |
| 3 | + |
| 4 | +package v1_24 //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 | +// TableIndices implements xorm's TableIndices interface |
| 33 | +func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index { |
| 34 | + repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType) |
| 35 | + repoIndex.AddColumn("repo_id", "user_id", "is_deleted") |
| 36 | + |
| 37 | + actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType) |
| 38 | + actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted") |
| 39 | + |
| 40 | + cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType) |
| 41 | + cudIndex.AddColumn("created_unix", "user_id", "is_deleted") |
| 42 | + |
| 43 | + cuIndex := schemas.NewIndex("c_u", schemas.IndexType) |
| 44 | + cuIndex.AddColumn("user_id", "is_deleted") |
| 45 | + |
| 46 | + actUserUserIndex := schemas.NewIndex("au_c_u", schemas.IndexType) |
| 47 | + actUserUserIndex.AddColumn("act_user_id", "created_unix", "user_id") |
| 48 | + |
| 49 | + indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex, cuIndex, actUserUserIndex} |
| 50 | + |
| 51 | + return indices |
| 52 | +} |
| 53 | + |
| 54 | +func AddNewIndexForUserDashboard(x *xorm.Engine) error { |
| 55 | + return x.Sync(new(improveActionTableIndicesAction)) |
| 56 | +} |
0 commit comments