summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAndrey Nering <andrey.nering@gmail.com>2017-01-06 13:14:33 -0200
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-06 23:14:33 +0800
commit84b7d29d34e0d51e0c67e2e35803e8e611da7965 (patch)
tree0f8a47ffac337f37fdf48f1b34c44b2ca269dd63 /models
parent1a7fc53c98f06f79955d217f91c8a5553e5a27b3 (diff)
downloadgitea-84b7d29d34e0d51e0c67e2e35803e8e611da7965.tar.gz
gitea-84b7d29d34e0d51e0c67e2e35803e8e611da7965.zip
Create missing database indexes (#596)
Diffstat (limited to 'models')
-rw-r--r--models/action.go10
-rw-r--r--models/admin.go2
-rw-r--r--models/issue.go30
-rw-r--r--models/issue_comment.go6
-rw-r--r--models/login_source.go6
-rw-r--r--models/org.go2
-rw-r--r--models/pull.go12
-rw-r--r--models/release.go10
-rw-r--r--models/repo.go14
-rw-r--r--models/repo_mirror.go8
-rw-r--r--models/token.go8
-rw-r--r--models/user.go8
-rw-r--r--models/webhook.go12
13 files changed, 64 insertions, 64 deletions
diff --git a/models/action.go b/models/action.go
index 8b3d82b4d6..112e9ec7b9 100644
--- a/models/action.go
+++ b/models/action.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
diff --git a/models/admin.go b/models/admin.go
index 058e9be8a8..9447ef67ea 100644
--- a/models/admin.go
+++ b/models/admin.go
@@ -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.
diff --git a/models/issue.go b/models/issue.go
index 315c91e159..b8f23d5948 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -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:"-"`
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 22c1e8cf91..73c9db1cdb 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -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)"`
diff --git a/models/login_source.go b/models/login_source.go
index 58e0e88b3e..3fe5e172e3 100644
--- a/models/login_source.go
+++ b/models/login_source.go
@@ -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.
diff --git a/models/org.go b/models/org.go
index 7fbd790f5b..7d64d5a917 100644
--- a/models/org.go
+++ b/models/org.go
@@ -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
}
diff --git a/models/pull.go b/models/pull.go
index 6231b71cb7..8661fa3aa8 100644
--- a/models/pull.go
+++ b/models/pull.go
@@ -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.
diff --git a/models/release.go b/models/release.go
index 28ba6c1d68..67ef81e21c 100644
--- a/models/release.go
+++ b/models/release.go
@@ -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.
diff --git a/models/repo.go b/models/repo.go
index 85807e3a4b..4acb0d736e 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -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.
diff --git a/models/repo_mirror.go b/models/repo_mirror.go
index 2cedf69d70..abe70de1ab 100644
--- a/models/repo_mirror.go
+++ b/models/repo_mirror.go
@@ -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:"-"`
}
diff --git a/models/token.go b/models/token.go
index 6b2898a49d..b2e0a28a5a 100644
--- a/models/token.go
+++ b/models/token.go
@@ -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.
diff --git a/models/user.go b/models/user.go
index 1dbd63dce0..201d8c48fa 100644
--- a/models/user.go
+++ b/models/user.go
@@ -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
diff --git a/models/webhook.go b/models/webhook.go
index 2da88de2a4..c9c3c21a46 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -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