diff --git a/models/fixtures/attachment.yml b/models/fixtures/attachment.yml index b86a15b2826..06f578f7b7b 100644 --- a/models/fixtures/attachment.yml +++ b/models/fixtures/attachment.yml @@ -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 diff --git a/models/migrations/v1_25/v321.go b/models/migrations/v1_25/v321.go index 0084b99eacb..0eb556259d1 100644 --- a/models/migrations/v1_25/v321.go +++ b/models/migrations/v1_25/v321.go @@ -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, diff --git a/models/repo/attachment.go b/models/repo/attachment.go index 1a03dbe8bf7..98f97d01e0b 100644 --- a/models/repo/attachment.go +++ b/models/repo/attachment.go @@ -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,