gitea源码

v146.go 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package v1_13
  4. import (
  5. "code.gitea.io/gitea/modules/timeutil"
  6. "xorm.io/xorm"
  7. )
  8. func AddProjectsInfo(x *xorm.Engine) error {
  9. // Create new tables
  10. type (
  11. ProjectType uint8
  12. ProjectBoardType uint8
  13. )
  14. type Project struct {
  15. ID int64 `xorm:"pk autoincr"`
  16. Title string `xorm:"INDEX NOT NULL"`
  17. Description string `xorm:"TEXT"`
  18. RepoID int64 `xorm:"INDEX"`
  19. CreatorID int64 `xorm:"NOT NULL"`
  20. IsClosed bool `xorm:"INDEX"`
  21. BoardType ProjectBoardType
  22. Type ProjectType
  23. ClosedDateUnix timeutil.TimeStamp
  24. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  25. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  26. }
  27. if err := x.Sync(new(Project)); err != nil {
  28. return err
  29. }
  30. type Comment struct {
  31. OldProjectID int64
  32. ProjectID int64
  33. }
  34. if err := x.Sync(new(Comment)); err != nil {
  35. return err
  36. }
  37. type Repository struct {
  38. ID int64
  39. NumProjects int `xorm:"NOT NULL DEFAULT 0"`
  40. NumClosedProjects int `xorm:"NOT NULL DEFAULT 0"`
  41. }
  42. if err := x.Sync(new(Repository)); err != nil {
  43. return err
  44. }
  45. // ProjectIssue saves relation from issue to a project
  46. type ProjectIssue struct {
  47. ID int64 `xorm:"pk autoincr"`
  48. IssueID int64 `xorm:"INDEX"`
  49. ProjectID int64 `xorm:"INDEX"`
  50. ProjectBoardID int64 `xorm:"INDEX"`
  51. }
  52. if err := x.Sync(new(ProjectIssue)); err != nil {
  53. return err
  54. }
  55. type ProjectBoard struct {
  56. ID int64 `xorm:"pk autoincr"`
  57. Title string
  58. Default bool `xorm:"NOT NULL DEFAULT false"`
  59. ProjectID int64 `xorm:"INDEX NOT NULL"`
  60. CreatorID int64 `xorm:"NOT NULL"`
  61. CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
  62. UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
  63. }
  64. return x.Sync(new(ProjectBoard))
  65. }