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