Create missing database indexes (#596)

tokarchuk/v1.17
Andrey Nering 8 years ago committed by Lunny Xiao
parent 1a7fc53c98
commit 84b7d29d34
  1. 10
      models/action.go
  2. 2
      models/admin.go
  3. 30
      models/issue.go
  4. 6
      models/issue_comment.go
  5. 6
      models/login_source.go
  6. 2
      models/org.go
  7. 12
      models/pull.go
  8. 10
      models/release.go
  9. 14
      models/repo.go
  10. 8
      models/repo_mirror.go
  11. 8
      models/token.go
  12. 8
      models/user.go
  13. 12
      models/webhook.go

@ -71,19 +71,19 @@ func init() {
// used in template render.
type Action struct {
ID int64 `xorm:"pk autoincr"`
UserID int64 // Receiver user id.
UserID int64 `xorm:"INDEX"` // Receiver user id.
OpType ActionType
ActUserID int64 // Action user id.
ActUserID int64 `xorm:"INDEX"` // Action user id.
ActUserName string // Action user name.
ActAvatar string `xorm:"-"`
RepoID int64
RepoID int64 `xorm:"INDEX"`
RepoUserName string
RepoName string
RefName string
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
Content string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert will be invoked by XORM before inserting a record

@ -32,7 +32,7 @@ type Notice struct {
Type NoticeType
Description string `xorm:"TEXT"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert is invoked from XORM before inserting an object of this type.

@ -34,29 +34,29 @@ type Issue struct {
RepoID int64 `xorm:"INDEX UNIQUE(repo_index)"`
Repo *Repository `xorm:"-"`
Index int64 `xorm:"UNIQUE(repo_index)"` // Index in one repository.
PosterID int64
Poster *User `xorm:"-"`
Title string `xorm:"name"`
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
Labels []*Label `xorm:"-"`
MilestoneID int64
Milestone *Milestone `xorm:"-"`
PosterID int64 `xorm:"INDEX"`
Poster *User `xorm:"-"`
Title string `xorm:"name"`
Content string `xorm:"TEXT"`
RenderedContent string `xorm:"-"`
Labels []*Label `xorm:"-"`
MilestoneID int64 `xorm:"INDEX"`
Milestone *Milestone `xorm:"-"`
Priority int
AssigneeID int64
Assignee *User `xorm:"-"`
IsClosed bool
AssigneeID int64 `xorm:"INDEX"`
Assignee *User `xorm:"-"`
IsClosed bool `xorm:"INDEX"`
IsRead bool `xorm:"-"`
IsPull bool // Indicates whether is a pull request or not.
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
PullRequest *PullRequest `xorm:"-"`
NumComments int
Deadline time.Time `xorm:"-"`
DeadlineUnix int64
DeadlineUnix int64 `xorm:"INDEX"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
Attachments []*Attachment `xorm:"-"`
Comments []*Comment `xorm:"-"`

@ -53,7 +53,7 @@ const (
type Comment struct {
ID int64 `xorm:"pk autoincr"`
Type CommentType
PosterID int64
PosterID int64 `xorm:"INDEX"`
Poster *User `xorm:"-"`
IssueID int64 `xorm:"INDEX"`
CommitID int64
@ -62,9 +62,9 @@ type Comment struct {
RenderedContent string `xorm:"-"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
// Reference issue in commit message
CommitSHA string `xorm:"VARCHAR(40)"`

@ -120,13 +120,13 @@ type LoginSource struct {
ID int64 `xorm:"pk autoincr"`
Type LoginType
Name string `xorm:"UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"`
IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert is invoked from XORM before inserting an object of this type.

@ -255,7 +255,7 @@ type OrgUser struct {
ID int64 `xorm:"pk autoincr"`
UID int64 `xorm:"INDEX UNIQUE(s)"`
OrgID int64 `xorm:"INDEX UNIQUE(s)"`
IsPublic bool
IsPublic bool `xorm:"INDEX"`
IsOwner bool
NumTeams int
}

@ -54,21 +54,21 @@ type PullRequest struct {
Issue *Issue `xorm:"-"`
Index int64
HeadRepoID int64
HeadRepoID int64 `xorm:"INDEX"`
HeadRepo *Repository `xorm:"-"`
BaseRepoID int64
BaseRepoID int64 `xorm:"INDEX"`
BaseRepo *Repository `xorm:"-"`
HeadUserName string
HeadBranch string
BaseBranch string
MergeBase string `xorm:"VARCHAR(40)"`
HasMerged bool
MergedCommitID string `xorm:"VARCHAR(40)"`
MergerID int64
HasMerged bool `xorm:"INDEX"`
MergedCommitID string `xorm:"VARCHAR(40)"`
MergerID int64 `xorm:"INDEX"`
Merger *User `xorm:"-"`
Merged time.Time `xorm:"-"`
MergedUnix int64
MergedUnix int64 `xorm:"INDEX"`
}
// BeforeUpdate is invoked from XORM before updating an object of this type.

@ -23,11 +23,11 @@ import (
// Release represents a release of repository.
type Release struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"index unique(n)"`
RepoID int64 `xorm:"INDEX UNIQUE(n)"`
Repo *Repository `xorm:"-"`
PublisherID int64
Publisher *User `xorm:"-"`
TagName string `xorm:"index unique(n)"`
PublisherID int64 `xorm:"INDEX"`
Publisher *User `xorm:"-"`
TagName string `xorm:"INDEX UNIQUE(n)"`
LowerTagName string
Target string
Title string
@ -39,7 +39,7 @@ type Release struct {
IsPrerelease bool
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert is invoked from XORM before inserting an object of this type.

@ -193,10 +193,10 @@ type Repository struct {
NumOpenMilestones int `xorm:"-"`
NumTags int `xorm:"-"`
IsPrivate bool
IsBare bool
IsPrivate bool `xorm:"INDEX"`
IsBare bool `xorm:"INDEX"`
IsMirror bool
IsMirror bool `xorm:"INDEX"`
*Mirror `xorm:"-"`
// Advanced settings
@ -211,14 +211,14 @@ type Repository struct {
ExternalMetas map[string]string `xorm:"-"`
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
IsFork bool `xorm:"NOT NULL DEFAULT false"`
ForkID int64
IsFork bool `xorm:"INDEX NOT NULL DEFAULT false"`
ForkID int64 `xorm:"INDEX"`
BaseRepo *Repository `xorm:"-"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert is invoked from XORM before inserting an object of this type.

@ -24,16 +24,16 @@ var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
// Mirror represents mirror information of a repository.
type Mirror struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX"`
Repo *Repository `xorm:"-"`
Interval int // Hour.
EnablePrune bool `xorm:"NOT NULL DEFAULT true"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
NextUpdate time.Time `xorm:"-"`
NextUpdateUnix int64
NextUpdateUnix int64 `xorm:"INDEX"`
address string `xorm:"-"`
}

@ -21,11 +21,11 @@ type AccessToken struct {
Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
UpdatedUnix int64
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
UpdatedUnix int64 `xorm:"INDEX"`
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
}
// BeforeInsert will be invoked by XORM before inserting a record representing this object.

@ -90,11 +90,11 @@ type User struct {
Salt string `xorm:"VARCHAR(10)"`
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
LastLogin time.Time `xorm:"-"`
LastLoginUnix int64
LastLoginUnix int64 `xorm:"INDEX"`
// Remember visibility choice for convenience, true for private
LastRepoVisibility bool
@ -102,7 +102,7 @@ type User struct {
MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"`
// Permissions
IsActive bool // Activate primary email
IsActive bool `xorm:"INDEX"` // Activate primary email
IsAdmin bool
AllowGitHook bool
AllowImportLocal bool // Allow migrate repository by local path

@ -91,24 +91,24 @@ const (
// Webhook represents a web hook object.
type Webhook struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64
OrgID int64
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX"`
OrgID int64 `xorm:"INDEX"`
URL string `xorm:"url TEXT"`
ContentType HookContentType
Secret string `xorm:"TEXT"`
Events string `xorm:"TEXT"`
*HookEvent `xorm:"-"`
IsSSL bool `xorm:"is_ssl"`
IsActive bool
IsActive bool `xorm:"INDEX"`
HookTaskType HookTaskType
Meta string `xorm:"TEXT"` // store hook-specific attributes
LastStatus HookStatus // Last delivery status
Created time.Time `xorm:"-"`
CreatedUnix int64
CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"`
UpdatedUnix int64
UpdatedUnix int64 `xorm:"INDEX"`
}
// BeforeInsert will be invoked by XORM before inserting a record

Loading…
Cancel
Save