This commit is contained in:
Lunny Xiao 2025-07-20 16:47:10 -07:00
parent fa5fc02cb8
commit 7134ad9051
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 32 additions and 19 deletions

View File

@ -8,6 +8,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -21,6 +22,7 @@
comment_id: 0
name: attach2
download_count: 1
status: 1
size: 0
created_unix: 946684800
@ -34,6 +36,7 @@
comment_id: 1
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -47,6 +50,7 @@
comment_id: 1
name: attach2
download_count: 1
status: 1
size: 0
created_unix: 946684800
@ -60,6 +64,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -73,6 +78,7 @@
comment_id: 2
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -86,6 +92,7 @@
comment_id: 2
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -99,6 +106,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -112,6 +120,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -125,6 +134,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -138,6 +148,7 @@
comment_id: 0
name: attach1
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -151,6 +162,7 @@
comment_id: 0
name: README.md
download_count: 0
status: 1
size: 0
created_unix: 946684800
@ -164,5 +176,6 @@
comment_id: 7
name: code_comment_uploaded_attachment.png
download_count: 0
status: 1
size: 0
created_unix: 946684812

View File

@ -13,16 +13,16 @@ import (
type Attachment321 struct {
ID int64 `xorm:"pk autoincr"`
UUID string `xorm:"uuid UNIQUE"`
RepoID int64 `xorm:"INDEX"` // this should not be zero
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added
CommentID int64 `xorm:"INDEX"`
UUID string `xorm:"uuid"`
RepoID int64 // this should not be zero
IssueID int64 // maybe zero when creating
ReleaseID int64 // maybe zero when creating
UploaderID int64 `xorm:"DEFAULT 0"` // Notice: will be zero before this column added
CommentID int64
Name string
DownloadCount int64 `xorm:"DEFAULT 0"`
Status db.FileStatus `xorm:"INDEX DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
Status db.FileStatus `xorm:"DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
LastDeleteFailedTime timeutil.TimeStamp // Last time the deletion failed, used to prevent infinite loop
Size int64 `xorm:"DEFAULT 0"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
@ -56,7 +56,7 @@ func (a *Attachment321) TableIndices() []*schemas.Index {
statusIndex.AddColumn("status")
statusIDIndex := schemas.NewIndex("attachment_status_id", schemas.IndexType)
statusIDIndex.AddColumn("status_id", "id") // For status = ? AND id > ? query
statusIDIndex.AddColumn("status", "id") // For status = ? AND id > ? query
return []*schemas.Index{
uuidIndex,

View File

@ -21,17 +21,17 @@ import (
// Attachment represent a attachment of issue/comment/release.
type Attachment struct {
ID int64 `xorm:"pk autoincr"`
UUID string `xorm:"uuid UNIQUE"`
RepoID int64 `xorm:"INDEX"` // this should not be zero
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
UploaderID int64 `xorm:"INDEX DEFAULT 0"` // Notice: will be zero before this column added
CommentID int64 `xorm:"INDEX"`
UUID string `xorm:"uuid"`
RepoID int64 // this should not be zero
IssueID int64 // maybe zero when creating
ReleaseID int64 // maybe zero when creating
UploaderID int64 `xorm:"DEFAULT 0"` // Notice: will be zero before this column added
CommentID int64
Name string
DownloadCount int64 `xorm:"DEFAULT 0"`
Status db.FileStatus `xorm:"INDEX DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
LastDeleteFailedReason string `xorm:"TEXT"` // Last reason the deletion failed, used to prevent infinite loop
Status db.FileStatus `xorm:"DEFAULT 1 NOT NULL"` // 1 = normal, 2 = to be deleted
DeleteFailedCount int `xorm:"DEFAULT 0"` // Number of times the deletion failed, used to prevent infinite loop
LastDeleteFailedReason string `xorm:"TEXT"` // Last reason the deletion failed, used to prevent infinite loop
LastDeleteFailedTime timeutil.TimeStamp // Last time the deletion failed, used to prevent infinite loop
Size int64 `xorm:"DEFAULT 0"`
CreatedUnix timeutil.TimeStamp `xorm:"created"`
@ -62,7 +62,7 @@ func (a *Attachment) TableIndices() []*schemas.Index {
statusIndex.AddColumn("status")
statusIDIndex := schemas.NewIndex("attachment_status_id", schemas.IndexType)
statusIDIndex.AddColumn("status_id", "id") // For status = ? AND id > ? query
statusIDIndex.AddColumn("status", "id") // For status = ? AND id > ? query
return []*schemas.Index{
uuidIndex,