Skip to content

Commit 84b7d29

Browse files
andreyneringlunny
authored andcommitted
Create missing database indexes (#596)
1 parent 1a7fc53 commit 84b7d29

File tree

13 files changed

+64
-64
lines changed

13 files changed

+64
-64
lines changed

models/action.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ func init() {
7171
// used in template render.
7272
type Action struct {
7373
ID int64 `xorm:"pk autoincr"`
74-
UserID int64 // Receiver user id.
74+
UserID int64 `xorm:"INDEX"` // Receiver user id.
7575
OpType ActionType
76-
ActUserID int64 // Action user id.
76+
ActUserID int64 `xorm:"INDEX"` // Action user id.
7777
ActUserName string // Action user name.
7878
ActAvatar string `xorm:"-"`
79-
RepoID int64
79+
RepoID int64 `xorm:"INDEX"`
8080
RepoUserName string
8181
RepoName string
8282
RefName string
83-
IsPrivate bool `xorm:"NOT NULL DEFAULT false"`
83+
IsPrivate bool `xorm:"INDEX NOT NULL DEFAULT false"`
8484
Content string `xorm:"TEXT"`
8585
Created time.Time `xorm:"-"`
86-
CreatedUnix int64
86+
CreatedUnix int64 `xorm:"INDEX"`
8787
}
8888

8989
// BeforeInsert will be invoked by XORM before inserting a record

models/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Notice struct {
3232
Type NoticeType
3333
Description string `xorm:"TEXT"`
3434
Created time.Time `xorm:"-"`
35-
CreatedUnix int64
35+
CreatedUnix int64 `xorm:"INDEX"`
3636
}
3737

3838
// BeforeInsert is invoked from XORM before inserting an object of this type.

models/issue.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ type Issue struct {
3434
RepoID int64 `xorm:"INDEX UNIQUE(repo_index)"`
3535
Repo *Repository `xorm:"-"`
3636
Index int64 `xorm:"UNIQUE(repo_index)"` // Index in one repository.
37-
PosterID int64
38-
Poster *User `xorm:"-"`
39-
Title string `xorm:"name"`
40-
Content string `xorm:"TEXT"`
41-
RenderedContent string `xorm:"-"`
42-
Labels []*Label `xorm:"-"`
43-
MilestoneID int64
44-
Milestone *Milestone `xorm:"-"`
37+
PosterID int64 `xorm:"INDEX"`
38+
Poster *User `xorm:"-"`
39+
Title string `xorm:"name"`
40+
Content string `xorm:"TEXT"`
41+
RenderedContent string `xorm:"-"`
42+
Labels []*Label `xorm:"-"`
43+
MilestoneID int64 `xorm:"INDEX"`
44+
Milestone *Milestone `xorm:"-"`
4545
Priority int
46-
AssigneeID int64
47-
Assignee *User `xorm:"-"`
48-
IsClosed bool
46+
AssigneeID int64 `xorm:"INDEX"`
47+
Assignee *User `xorm:"-"`
48+
IsClosed bool `xorm:"INDEX"`
4949
IsRead bool `xorm:"-"`
50-
IsPull bool // Indicates whether is a pull request or not.
50+
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
5151
PullRequest *PullRequest `xorm:"-"`
5252
NumComments int
5353

5454
Deadline time.Time `xorm:"-"`
55-
DeadlineUnix int64
55+
DeadlineUnix int64 `xorm:"INDEX"`
5656
Created time.Time `xorm:"-"`
57-
CreatedUnix int64
57+
CreatedUnix int64 `xorm:"INDEX"`
5858
Updated time.Time `xorm:"-"`
59-
UpdatedUnix int64
59+
UpdatedUnix int64 `xorm:"INDEX"`
6060

6161
Attachments []*Attachment `xorm:"-"`
6262
Comments []*Comment `xorm:"-"`

models/issue_comment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const (
5353
type Comment struct {
5454
ID int64 `xorm:"pk autoincr"`
5555
Type CommentType
56-
PosterID int64
56+
PosterID int64 `xorm:"INDEX"`
5757
Poster *User `xorm:"-"`
5858
IssueID int64 `xorm:"INDEX"`
5959
CommitID int64
@@ -62,9 +62,9 @@ type Comment struct {
6262
RenderedContent string `xorm:"-"`
6363

6464
Created time.Time `xorm:"-"`
65-
CreatedUnix int64
65+
CreatedUnix int64 `xorm:"INDEX"`
6666
Updated time.Time `xorm:"-"`
67-
UpdatedUnix int64
67+
UpdatedUnix int64 `xorm:"INDEX"`
6868

6969
// Reference issue in commit message
7070
CommitSHA string `xorm:"VARCHAR(40)"`

models/login_source.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,13 @@ type LoginSource struct {
120120
ID int64 `xorm:"pk autoincr"`
121121
Type LoginType
122122
Name string `xorm:"UNIQUE"`
123-
IsActived bool `xorm:"NOT NULL DEFAULT false"`
123+
IsActived bool `xorm:"INDEX NOT NULL DEFAULT false"`
124124
Cfg core.Conversion `xorm:"TEXT"`
125125

126126
Created time.Time `xorm:"-"`
127-
CreatedUnix int64
127+
CreatedUnix int64 `xorm:"INDEX"`
128128
Updated time.Time `xorm:"-"`
129-
UpdatedUnix int64
129+
UpdatedUnix int64 `xorm:"INDEX"`
130130
}
131131

132132
// BeforeInsert is invoked from XORM before inserting an object of this type.

models/org.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ type OrgUser struct {
255255
ID int64 `xorm:"pk autoincr"`
256256
UID int64 `xorm:"INDEX UNIQUE(s)"`
257257
OrgID int64 `xorm:"INDEX UNIQUE(s)"`
258-
IsPublic bool
258+
IsPublic bool `xorm:"INDEX"`
259259
IsOwner bool
260260
NumTeams int
261261
}

models/pull.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ type PullRequest struct {
5454
Issue *Issue `xorm:"-"`
5555
Index int64
5656

57-
HeadRepoID int64
57+
HeadRepoID int64 `xorm:"INDEX"`
5858
HeadRepo *Repository `xorm:"-"`
59-
BaseRepoID int64
59+
BaseRepoID int64 `xorm:"INDEX"`
6060
BaseRepo *Repository `xorm:"-"`
6161
HeadUserName string
6262
HeadBranch string
6363
BaseBranch string
6464
MergeBase string `xorm:"VARCHAR(40)"`
6565

66-
HasMerged bool
67-
MergedCommitID string `xorm:"VARCHAR(40)"`
68-
MergerID int64
66+
HasMerged bool `xorm:"INDEX"`
67+
MergedCommitID string `xorm:"VARCHAR(40)"`
68+
MergerID int64 `xorm:"INDEX"`
6969
Merger *User `xorm:"-"`
7070
Merged time.Time `xorm:"-"`
71-
MergedUnix int64
71+
MergedUnix int64 `xorm:"INDEX"`
7272
}
7373

7474
// BeforeUpdate is invoked from XORM before updating an object of this type.

models/release.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import (
2323
// Release represents a release of repository.
2424
type Release struct {
2525
ID int64 `xorm:"pk autoincr"`
26-
RepoID int64 `xorm:"index unique(n)"`
26+
RepoID int64 `xorm:"INDEX UNIQUE(n)"`
2727
Repo *Repository `xorm:"-"`
28-
PublisherID int64
29-
Publisher *User `xorm:"-"`
30-
TagName string `xorm:"index unique(n)"`
28+
PublisherID int64 `xorm:"INDEX"`
29+
Publisher *User `xorm:"-"`
30+
TagName string `xorm:"INDEX UNIQUE(n)"`
3131
LowerTagName string
3232
Target string
3333
Title string
@@ -39,7 +39,7 @@ type Release struct {
3939
IsPrerelease bool
4040

4141
Created time.Time `xorm:"-"`
42-
CreatedUnix int64
42+
CreatedUnix int64 `xorm:"INDEX"`
4343
}
4444

4545
// BeforeInsert is invoked from XORM before inserting an object of this type.

models/repo.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ type Repository struct {
193193
NumOpenMilestones int `xorm:"-"`
194194
NumTags int `xorm:"-"`
195195

196-
IsPrivate bool
197-
IsBare bool
196+
IsPrivate bool `xorm:"INDEX"`
197+
IsBare bool `xorm:"INDEX"`
198198

199-
IsMirror bool
199+
IsMirror bool `xorm:"INDEX"`
200200
*Mirror `xorm:"-"`
201201

202202
// Advanced settings
@@ -211,14 +211,14 @@ type Repository struct {
211211
ExternalMetas map[string]string `xorm:"-"`
212212
EnablePulls bool `xorm:"NOT NULL DEFAULT true"`
213213

214-
IsFork bool `xorm:"NOT NULL DEFAULT false"`
215-
ForkID int64
214+
IsFork bool `xorm:"INDEX NOT NULL DEFAULT false"`
215+
ForkID int64 `xorm:"INDEX"`
216216
BaseRepo *Repository `xorm:"-"`
217217

218218
Created time.Time `xorm:"-"`
219-
CreatedUnix int64
219+
CreatedUnix int64 `xorm:"INDEX"`
220220
Updated time.Time `xorm:"-"`
221-
UpdatedUnix int64
221+
UpdatedUnix int64 `xorm:"INDEX"`
222222
}
223223

224224
// BeforeInsert is invoked from XORM before inserting an object of this type.

models/repo_mirror.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ var MirrorQueue = sync.NewUniqueQueue(setting.Repository.MirrorQueueLength)
2424

2525
// Mirror represents mirror information of a repository.
2626
type Mirror struct {
27-
ID int64 `xorm:"pk autoincr"`
28-
RepoID int64
27+
ID int64 `xorm:"pk autoincr"`
28+
RepoID int64 `xorm:"INDEX"`
2929
Repo *Repository `xorm:"-"`
3030
Interval int // Hour.
3131
EnablePrune bool `xorm:"NOT NULL DEFAULT true"`
3232

3333
Updated time.Time `xorm:"-"`
34-
UpdatedUnix int64
34+
UpdatedUnix int64 `xorm:"INDEX"`
3535
NextUpdate time.Time `xorm:"-"`
36-
NextUpdateUnix int64
36+
NextUpdateUnix int64 `xorm:"INDEX"`
3737

3838
address string `xorm:"-"`
3939
}

models/token.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ type AccessToken struct {
2121
Sha1 string `xorm:"UNIQUE VARCHAR(40)"`
2222

2323
Created time.Time `xorm:"-"`
24-
CreatedUnix int64
24+
CreatedUnix int64 `xorm:"INDEX"`
2525
Updated time.Time `xorm:"-"` // Note: Updated must below Created for AfterSet.
26-
UpdatedUnix int64
27-
HasRecentActivity bool `xorm:"-"`
28-
HasUsed bool `xorm:"-"`
26+
UpdatedUnix int64 `xorm:"INDEX"`
27+
HasRecentActivity bool `xorm:"-"`
28+
HasUsed bool `xorm:"-"`
2929
}
3030

3131
// BeforeInsert will be invoked by XORM before inserting a record representing this object.

models/user.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,19 @@ type User struct {
9090
Salt string `xorm:"VARCHAR(10)"`
9191

9292
Created time.Time `xorm:"-"`
93-
CreatedUnix int64
93+
CreatedUnix int64 `xorm:"INDEX"`
9494
Updated time.Time `xorm:"-"`
95-
UpdatedUnix int64
95+
UpdatedUnix int64 `xorm:"INDEX"`
9696
LastLogin time.Time `xorm:"-"`
97-
LastLoginUnix int64
97+
LastLoginUnix int64 `xorm:"INDEX"`
9898

9999
// Remember visibility choice for convenience, true for private
100100
LastRepoVisibility bool
101101
// Maximum repository creation limit, -1 means use global default
102102
MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"`
103103

104104
// Permissions
105-
IsActive bool // Activate primary email
105+
IsActive bool `xorm:"INDEX"` // Activate primary email
106106
IsAdmin bool
107107
AllowGitHook bool
108108
AllowImportLocal bool // Allow migrate repository by local path

models/webhook.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,24 @@ const (
9191

9292
// Webhook represents a web hook object.
9393
type Webhook struct {
94-
ID int64 `xorm:"pk autoincr"`
95-
RepoID int64
96-
OrgID int64
94+
ID int64 `xorm:"pk autoincr"`
95+
RepoID int64 `xorm:"INDEX"`
96+
OrgID int64 `xorm:"INDEX"`
9797
URL string `xorm:"url TEXT"`
9898
ContentType HookContentType
9999
Secret string `xorm:"TEXT"`
100100
Events string `xorm:"TEXT"`
101101
*HookEvent `xorm:"-"`
102102
IsSSL bool `xorm:"is_ssl"`
103-
IsActive bool
103+
IsActive bool `xorm:"INDEX"`
104104
HookTaskType HookTaskType
105105
Meta string `xorm:"TEXT"` // store hook-specific attributes
106106
LastStatus HookStatus // Last delivery status
107107

108108
Created time.Time `xorm:"-"`
109-
CreatedUnix int64
109+
CreatedUnix int64 `xorm:"INDEX"`
110110
Updated time.Time `xorm:"-"`
111-
UpdatedUnix int64
111+
UpdatedUnix int64 `xorm:"INDEX"`
112112
}
113113

114114
// BeforeInsert will be invoked by XORM before inserting a record

0 commit comments

Comments
 (0)