Skip to content

Commit 7134ad9

Browse files
committed
Fix test
1 parent fa5fc02 commit 7134ad9

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

models/fixtures/attachment.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
comment_id: 0
99
name: attach1
1010
download_count: 0
11+
status: 1
1112
size: 0
1213
created_unix: 946684800
1314

@@ -21,6 +22,7 @@
2122
comment_id: 0
2223
name: attach2
2324
download_count: 1
25+
status: 1
2426
size: 0
2527
created_unix: 946684800
2628

@@ -34,6 +36,7 @@
3436
comment_id: 1
3537
name: attach1
3638
download_count: 0
39+
status: 1
3740
size: 0
3841
created_unix: 946684800
3942

@@ -47,6 +50,7 @@
4750
comment_id: 1
4851
name: attach2
4952
download_count: 1
53+
status: 1
5054
size: 0
5155
created_unix: 946684800
5256

@@ -60,6 +64,7 @@
6064
comment_id: 0
6165
name: attach1
6266
download_count: 0
67+
status: 1
6368
size: 0
6469
created_unix: 946684800
6570

@@ -73,6 +78,7 @@
7378
comment_id: 2
7479
name: attach1
7580
download_count: 0
81+
status: 1
7682
size: 0
7783
created_unix: 946684800
7884

@@ -86,6 +92,7 @@
8692
comment_id: 2
8793
name: attach1
8894
download_count: 0
95+
status: 1
8996
size: 0
9097
created_unix: 946684800
9198

@@ -99,6 +106,7 @@
99106
comment_id: 0
100107
name: attach1
101108
download_count: 0
109+
status: 1
102110
size: 0
103111
created_unix: 946684800
104112

@@ -112,6 +120,7 @@
112120
comment_id: 0
113121
name: attach1
114122
download_count: 0
123+
status: 1
115124
size: 0
116125
created_unix: 946684800
117126

@@ -125,6 +134,7 @@
125134
comment_id: 0
126135
name: attach1
127136
download_count: 0
137+
status: 1
128138
size: 0
129139
created_unix: 946684800
130140

@@ -138,6 +148,7 @@
138148
comment_id: 0
139149
name: attach1
140150
download_count: 0
151+
status: 1
141152
size: 0
142153
created_unix: 946684800
143154

@@ -151,6 +162,7 @@
151162
comment_id: 0
152163
name: README.md
153164
download_count: 0
165+
status: 1
154166
size: 0
155167
created_unix: 946684800
156168

@@ -164,5 +176,6 @@
164176
comment_id: 7
165177
name: code_comment_uploaded_attachment.png
166178
download_count: 0
179+
status: 1
167180
size: 0
168181
created_unix: 946684812

models/migrations/v1_25/v321.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import (
1313

1414
type Attachment321 struct {
1515
ID int64 `xorm:"pk autoincr"`
16-
UUID string `xorm:"uuid UNIQUE"`
17-
RepoID int64 `xorm:"INDEX"` // this should not be zero
18-
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
19-
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
20-
UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added
21-
CommentID int64 `xorm:"INDEX"`
16+
UUID string `xorm:"uuid"`
17+
RepoID int64 // this should not be zero
18+
IssueID int64 // maybe zero when creating
19+
ReleaseID int64 // maybe zero when creating
20+
UploaderID int64 `xorm:"DEFAULT 0"` // Notice: will be zero before this column added
21+
CommentID int64
2222
Name string
2323
DownloadCount int64 `xorm:"DEFAULT 0"`
24-
Status db.FileStatus `xorm:"INDEX DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
25-
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
24+
Status db.FileStatus `xorm:"DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
25+
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
2626
LastDeleteFailedTime timeutil.TimeStamp // Last time the deletion failed, used to prevent infinite loop
2727
Size int64 `xorm:"DEFAULT 0"`
2828
CreatedUnix timeutil.TimeStamp `xorm:"created"`
@@ -56,7 +56,7 @@ func (a *Attachment321) TableIndices() []*schemas.Index {
5656
statusIndex.AddColumn("status")
5757

5858
statusIDIndex := schemas.NewIndex("attachment_status_id", schemas.IndexType)
59-
statusIDIndex.AddColumn("status_id", "id") // For status = ? AND id > ? query
59+
statusIDIndex.AddColumn("status", "id") // For status = ? AND id > ? query
6060

6161
return []*schemas.Index{
6262
uuidIndex,

models/repo/attachment.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ import (
2121
// Attachment represent a attachment of issue/comment/release.
2222
type Attachment struct {
2323
ID int64 `xorm:"pk autoincr"`
24-
UUID string `xorm:"uuid UNIQUE"`
25-
RepoID int64 `xorm:"INDEX"` // this should not be zero
26-
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
27-
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
28-
UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added
29-
CommentID int64 `xorm:"INDEX"`
24+
UUID string `xorm:"uuid"`
25+
RepoID int64 // this should not be zero
26+
IssueID int64 // maybe zero when creating
27+
ReleaseID int64 // maybe zero when creating
28+
UploaderID int64 `xorm:"DEFAULT 0"` // Notice: will be zero before this column added
29+
CommentID int64
3030
Name string
3131
DownloadCount int64 `xorm:"DEFAULT 0"`
32-
Status db.FileStatus `xorm:"INDEX DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
33-
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
34-
LastDeleteFailedReason string `xorm:"TEXT"` // Last reason the deletion failed, used to prevent infinite loop
32+
Status db.FileStatus `xorm:"DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
33+
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
34+
LastDeleteFailedReason string `xorm:"TEXT"` // Last reason the deletion failed, used to prevent infinite loop
3535
LastDeleteFailedTime timeutil.TimeStamp // Last time the deletion failed, used to prevent infinite loop
3636
Size int64 `xorm:"DEFAULT 0"`
3737
CreatedUnix timeutil.TimeStamp `xorm:"created"`
@@ -62,7 +62,7 @@ func (a *Attachment) TableIndices() []*schemas.Index {
6262
statusIndex.AddColumn("status")
6363

6464
statusIDIndex := schemas.NewIndex("attachment_status_id", schemas.IndexType)
65-
statusIDIndex.AddColumn("status_id", "id") // For status = ? AND id > ? query
65+
statusIDIndex.AddColumn("status", "id") // For status = ? AND id > ? query
6666

6767
return []*schemas.Index{
6868
uuidIndex,

0 commit comments

Comments
 (0)