gitea源码

v317.go 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_24
  4. import (
  5. "code.gitea.io/gitea/modules/timeutil"
  6. "xorm.io/xorm"
  7. "xorm.io/xorm/schemas"
  8. )
  9. type improveActionTableIndicesAction struct {
  10. ID int64 `xorm:"pk autoincr"`
  11. UserID int64 `xorm:"INDEX"` // Receiver user id.
  12. OpType int
  13. ActUserID int64 // Action user id.
  14. RepoID int64
  15. CommentID int64 `xorm:"INDEX"`
  16. IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
  17. RefName string
  18. IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
  19. Content string `xorm:"TEXT"`
  20. CreatedUnix timeutil.TimeStamp `xorm:"created"`
  21. }
  22. // TableName sets the name of this table
  23. func (*improveActionTableIndicesAction) TableName() string {
  24. return "action"
  25. }
  26. // TableIndices implements xorm's TableIndices interface
  27. func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {
  28. repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
  29. repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
  30. actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
  31. actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
  32. cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
  33. cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
  34. cuIndex := schemas.NewIndex("c_u", schemas.IndexType)
  35. cuIndex.AddColumn("user_id", "is_deleted")
  36. actUserUserIndex := schemas.NewIndex("au_c_u", schemas.IndexType)
  37. actUserUserIndex.AddColumn("act_user_id", "created_unix", "user_id")
  38. indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex, cuIndex, actUserUserIndex}
  39. return indices
  40. }
  41. func AddNewIndexForUserDashboard(x *xorm.Engine) error {
  42. return x.Sync(new(improveActionTableIndicesAction))
  43. }