gitea源码

v249.go 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_20
  4. import (
  5. "code.gitea.io/gitea/modules/timeutil"
  6. "xorm.io/xorm"
  7. "xorm.io/xorm/schemas"
  8. )
  9. type Action struct {
  10. UserID int64 // Receiver user id.
  11. ActUserID int64 // Action user id.
  12. RepoID int64
  13. IsDeleted bool `xorm:"NOT NULL DEFAULT false"`
  14. IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
  15. CreatedUnix timeutil.TimeStamp `xorm:"created"`
  16. }
  17. // TableName sets the name of this table
  18. func (a *Action) TableName() string {
  19. return "action"
  20. }
  21. // TableIndices implements xorm's TableIndices interface
  22. func (a *Action) TableIndices() []*schemas.Index {
  23. repoIndex := schemas.NewIndex("r_u_d", schemas.IndexType)
  24. repoIndex.AddColumn("repo_id", "user_id", "is_deleted")
  25. actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
  26. actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
  27. cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
  28. cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
  29. indices := []*schemas.Index{actUserIndex, repoIndex, cudIndex}
  30. return indices
  31. }
  32. func ImproveActionTableIndices(x *xorm.Engine) error {
  33. return x.Sync(new(Action))
  34. }