Create missing database indexes (#596)

This commit is contained in:
Andrey Nering 2017-01-06 13:14:33 -02:00 committed by Lunny Xiao
parent 1a7fc53c98
commit 84b7d29d34
13 changed files with 64 additions and 64 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -21,9 +21,9 @@ type AccessToken struct {
Sha1 string `xorm:"UNIQUE VARCHAR(40)"` Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
Created time.Time `xorm:"-"` Created time.Time `xorm:"-"`
CreatedUnix int64 CreatedUnix int64 `xorm:"INDEX"`
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet. Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
UpdatedUnix int64 UpdatedUnix int64 `xorm:"INDEX"`
HasRecentActivity bool `xorm:"-"` HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"` HasUsed bool `xorm:"-"`
} }

View File

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

View File

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