Skip to content

Create missing database indexes #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions models/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion models/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 15 additions & 15 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
Expand Down
6 changes: 3 additions & 3 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"`
Expand Down
6 changes: 3 additions & 3 deletions models/login_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion models/org.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,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
}
Expand Down
12 changes: 6 additions & 6 deletions models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,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.
Expand Down
6 changes: 3 additions & 3 deletions models/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
// Release represents a release of repository.
type Release struct {
ID int64 `xorm:"pk autoincr"`
RepoID int64
PublisherID int64
RepoID int64 `xorm:"INDEX"`
PublisherID int64 `xorm:"INDEX"`
Publisher *User `xorm:"-"`
TagName string
LowerTagName string
Expand All @@ -35,7 +35,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.
Expand Down
14 changes: 7 additions & 7 deletions models/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions models/repo_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:"-"`
}
Expand Down
8 changes: 4 additions & 4 deletions models/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ 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
// Maximum repository creation limit, -1 means use global default
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
Expand Down
12 changes: 6 additions & 6 deletions models/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down