1-
21// Copyright 2025 The Gitea Authors. All rights reserved.
32// SPDX-License-Identifier: MIT
43
54package v1_24 //nolint
65
76import (
7+ "code.gitea.io/gitea/modules/timeutil"
8+
89 "xorm.io/xorm"
10+ "xorm.io/xorm/schemas"
911)
1012
11- // Permission copied from models.actions.Permission
12- type Permission int
13-
14- const (
15- PermissionUnspecified Permission = iota
16- PermissionNone
17- PermissionRead
18- PermissionWrite
19- )
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+ }
2026
21- // Permissions copied from models.actions.Permissions
22- type Permissions struct {
23- Actions Permission `yaml:"actions"`
24- Checks Permission `yaml:"checks"`
25- Contents Permission `yaml:"contents"`
26- Deployments Permission `yaml:"deployments"`
27- IDToken Permission `yaml:"id-token"`
28- Issues Permission `yaml:"issues"`
29- Discussions Permission `yaml:"discussions"`
30- Packages Permission `yaml:"packages"`
31- Pages Permission `yaml:"pages"`
32- PullRequests Permission `yaml:"pull-requests"`
33- RepositoryProjects Permission `yaml:"repository-projects"`
34- SecurityEvents Permission `yaml:"security-events"`
35- Statuses Permission `yaml:"statuses"`
27+ // TableName sets the name of this table
28+ func (* improveActionTableIndicesAction ) TableName () string {
29+ return "action"
3630}
3731
38- func AddPermissions (x * xorm.Engine ) error {
39- type ActionRunJob struct {
40- Permissions Permissions `xorm:"JSON TEXT"`
41- }
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" )
4242
43- return x .Sync (new (ActionRunJob ))
44- }
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