Skip to content

Commit

Permalink
⚡ 数据库索引
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Dec 28, 2017
1 parent faa23bd commit d0617d4
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion model/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ type Archive struct {
Month string `gorm:"size:2" json:"month"`
ArticleCount int `json:"articleCount"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}
4 changes: 2 additions & 2 deletions model/article.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Article struct {
Tags string `gorm:"size:128" json:"tags"`
Content string `gorm:"type:text" json:"content"`
Path string `sql:"index" gorm:"size:255" json:"path"`
Status int `json:"status"`
Status int `sql:"index" json:"status"`
Topped bool `json:"topped"`
Commentable bool `json:"commentable"`
ViewCount int `json:"viewCount"`
Expand All @@ -38,7 +38,7 @@ type Article struct {
UserAgent string `gorm:"size:255" json:"userAgent"`
PushedAt time.Time `json:"pushedAt"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}

// Article statuses.
Expand Down
2 changes: 1 addition & 1 deletion model/category.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ type Category struct {
Tags string `gorm:"size:128" json:"tags"`
Number int `json:"number"` // for sorting

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}
2 changes: 1 addition & 1 deletion model/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ type Comment struct {
UserAgent string `gorm:"size:255" json:"userAgent"`
PushedAt time.Time `json:"pushedAt"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}
2 changes: 1 addition & 1 deletion model/correlation.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ type Correlation struct {
Int4 int `json:int4`
Type int `json:"type"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}
2 changes: 1 addition & 1 deletion model/navigation.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Navigation struct {
OpenMethod string `gorm:"size:32" json:"openMethod"`
Number int `json:"number"` // for sorting

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}

// Navigation open methods.
Expand Down
2 changes: 1 addition & 1 deletion model/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Setting struct {
Name string `gorm:"size:32" json:"name"`
Value string `gorm:"type:text" json:"value"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}

// Setting names of category "system".
Expand Down
2 changes: 1 addition & 1 deletion model/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ type Tag struct {
Title string `gorm:"size:128" json:"title"`
ArticleCount int `json:"articleCount"`

BlogID uint `json:"blogID"`
BlogID uint `sql:"index" json:"blogID"`
}
2 changes: 1 addition & 1 deletion service/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func ConnectDB() {
logger.Fatal("adds index failed: " + err.Error())
}

// db.LogMode(true)
db.LogMode(true)
}

func DisconnectDB() {
Expand Down

0 comments on commit d0617d4

Please sign in to comment.