File tree Expand file tree Collapse file tree 6 files changed +46
-1
lines changed Expand file tree Collapse file tree 6 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ type Milestone struct {
31
31
Completeness int // Percentage(1-100).
32
32
IsOverdue bool `xorm:"-"`
33
33
34
- DeadlineString string `xorm:"-"`
34
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
35
+ UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
35
36
DeadlineUnix timeutil.TimeStamp
36
37
ClosedDateUnix timeutil.TimeStamp
38
+ DeadlineString string `xorm:"-"`
37
39
38
40
TotalTrackedTime int64 `xorm:"-"`
39
41
}
Original file line number Diff line number Diff line change @@ -228,6 +228,8 @@ var migrations = []Migration{
228
228
NewMigration ("Add projects info to repository table" , addProjectsInfo ),
229
229
// v147 -> v148
230
230
NewMigration ("create review for 0 review id code comments" , createReviewsForCodeComments ),
231
+ // v148 -> v149
232
+ NewMigration ("Add Created and Updated to Milestone table" , addCreatedAndUpdatedToMilestones ),
231
233
}
232
234
233
235
// GetCurrentDBVersion returns the current db version
Original file line number Diff line number Diff line change
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
+
5
+ package migrations
6
+
7
+ import (
8
+ "fmt"
9
+
10
+ "code.gitea.io/gitea/modules/timeutil"
11
+
12
+ "xorm.io/xorm"
13
+ )
14
+
15
+ func addCreatedAndUpdatedToMilestones (x * xorm.Engine ) error {
16
+ type Milestone struct {
17
+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
18
+ UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
19
+ }
20
+
21
+ if err := x .Sync2 (new (Milestone )); err != nil {
22
+ return fmt .Errorf ("Sync2: %v" , err )
23
+ }
24
+ return nil
25
+ }
Original file line number Diff line number Diff line change @@ -152,6 +152,8 @@ func ToAPIMilestone(m *models.Milestone) *api.Milestone {
152
152
Description : m .Content ,
153
153
OpenIssues : m .NumOpenIssues ,
154
154
ClosedIssues : m .NumClosedIssues ,
155
+ Created : m .CreatedUnix .AsTime (),
156
+ Updated : m .UpdatedUnix .AsTimePtr (),
155
157
}
156
158
if m .IsClosed {
157
159
apiMilestone .Closed = m .ClosedDateUnix .AsTimePtr ()
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ type Milestone struct {
17
17
OpenIssues int `json:"open_issues"`
18
18
ClosedIssues int `json:"closed_issues"`
19
19
// swagger:strfmt date-time
20
+ Created time.Time `json:"created_at"`
21
+ // swagger:strfmt date-time
22
+ Updated * time.Time `json:"updated_at"`
23
+ // swagger:strfmt date-time
20
24
Closed * time.Time `json:"closed_at"`
21
25
// swagger:strfmt date-time
22
26
Deadline * time.Time `json:"due_on"`
Original file line number Diff line number Diff line change 13527
13527
"format": "int64",
13528
13528
"x-go-name": "ClosedIssues"
13529
13529
},
13530
+ "created_at": {
13531
+ "type": "string",
13532
+ "format": "date-time",
13533
+ "x-go-name": "Created"
13534
+ },
13530
13535
"description": {
13531
13536
"type": "string",
13532
13537
"x-go-name": "Description"
13552
13557
"title": {
13553
13558
"type": "string",
13554
13559
"x-go-name": "Title"
13560
+ },
13561
+ "updated_at": {
13562
+ "type": "string",
13563
+ "format": "date-time",
13564
+ "x-go-name": "Updated"
13555
13565
}
13556
13566
},
13557
13567
"x-go-package": "code.gitea.io/gitea/modules/structs"
You can’t perform that action at this time.
0 commit comments