gitea源码

v308.go 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2024 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_23
  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. func (a *improveActionTableIndicesAction) TableIndices() []*schemas.Index {
  27. repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
  28. repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
  29. actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
  30. actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
  31. cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
  32. cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
  33. cuIndex := schemas.NewIndex("c_u", schemas.IndexType)
  34. cuIndex.AddColumn("user_id", "is_deleted")
  35. indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex, cuIndex}
  36. return indices
  37. }
  38. func AddNewIndexForUserDashboard(x *xorm.Engine) error {
  39. return x.Sync(new(improveActionTableIndicesAction))
  40. }