You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
1.9 KiB

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