From 358b569bf1517544f13920026a8174cf0bf9a104 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 5 Oct 2018 18:46:01 +0200 Subject: [PATCH] Addded indecies everywhere --- models/list.go | 4 ++-- models/list_items.go | 8 ++++---- models/list_users.go | 6 +++--- models/namespace_users.go | 6 +++--- models/namespaces.go | 2 +- models/team_list.go | 6 +++--- models/team_namespace.go | 6 +++--- models/teams.go | 8 ++++---- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/models/list.go b/models/list.go index 0572d407..5302c0b4 100644 --- a/models/list.go +++ b/models/list.go @@ -5,8 +5,8 @@ type List struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"list"` Title string `xorm:"varchar(250)" json:"title"` Description string `xorm:"varchar(1000)" json:"description"` - OwnerID int64 `xorm:"int(11)" json:"-"` - NamespaceID int64 `xorm:"int(11)" json:"-" param:"namespace"` + OwnerID int64 `xorm:"int(11) INDEX" json:"-"` + NamespaceID int64 `xorm:"int(11) INDEX" json:"-" param:"namespace"` Owner User `xorm:"-" json:"owner"` Tasks []*ListTask `xorm:"-" json:"tasks"` diff --git a/models/list_items.go b/models/list_items.go index 699febd3..0ff856d3 100644 --- a/models/list_items.go +++ b/models/list_items.go @@ -5,11 +5,11 @@ type ListTask struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"` Text string `xorm:"varchar(250)" json:"text"` Description string `xorm:"varchar(250)" json:"description"` - Done bool `json:"done"` - DueDateUnix int64 `xorm:"int(11)" json:"dueDate"` - ReminderUnix int64 `xorm:"int(11)" json:"reminderDate"` + Done bool `xorm:"INDEX" json:"done"` + DueDateUnix int64 `xorm:"int(11) INDEX" json:"dueDate"` + ReminderUnix int64 `xorm:"int(11) INDEX" json:"reminderDate"` CreatedByID int64 `xorm:"int(11)" json:"-"` // ID of the user who put that task on the list - ListID int64 `xorm:"int(11)" json:"listID" param:"list"` + ListID int64 `xorm:"int(11) INDEX" json:"listID" param:"list"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/models/list_users.go b/models/list_users.go index 8df82247..67762f8d 100644 --- a/models/list_users.go +++ b/models/list_users.go @@ -3,9 +3,9 @@ package models // ListUser represents a list <-> user relation type ListUser struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` - UserID int64 `xorm:"int(11) not null" json:"user_id" param:"user"` - ListID int64 `xorm:"int(11) not null" json:"list_id" param:"list"` - Right UserRight `xorm:"int(11)" json:"right"` + UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"` + ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"` + Right UserRight `xorm:"int(11) INDEX" json:"right"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/models/namespace_users.go b/models/namespace_users.go index 0c4f6baf..1e322ccb 100644 --- a/models/namespace_users.go +++ b/models/namespace_users.go @@ -3,9 +3,9 @@ package models // NamespaceUser represents a namespace <-> user relation type NamespaceUser struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` - UserID int64 `xorm:"int(11) not null" json:"user_id" param:"user"` - NamespaceID int64 `xorm:"int(11) not null" json:"namespace_id" param:"namespace"` - Right UserRight `xorm:"int(11)" json:"right"` + UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"` + NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"` + Right UserRight `xorm:"int(11) INDEX" json:"right"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/models/namespaces.go b/models/namespaces.go index 0bba23b1..bb35ceb4 100644 --- a/models/namespaces.go +++ b/models/namespaces.go @@ -5,7 +5,7 @@ type Namespace struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"` Name string `xorm:"varchar(250)" json:"name"` Description string `xorm:"varchar(1000)" json:"description"` - OwnerID int64 `xorm:"int(11) not null" json:"-"` + OwnerID int64 `xorm:"int(11) not null INDEX" json:"-"` Owner User `xorm:"-" json:"owner"` diff --git a/models/team_list.go b/models/team_list.go index c4bae56e..90e74e0a 100644 --- a/models/team_list.go +++ b/models/team_list.go @@ -3,9 +3,9 @@ package models // TeamList defines the relation between a team and a list type TeamList struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - TeamID int64 `xorm:"int(11) not null" json:"team_id" param:"team"` - ListID int64 `xorm:"int(11) not null" json:"list_id" param:"list"` - Right TeamRight `xorm:"int(11)" json:"right"` + TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"` + ListID int64 `xorm:"int(11) not null INDEX" json:"list_id" param:"list"` + Right TeamRight `xorm:"int(11) INDEX" json:"right"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/models/team_namespace.go b/models/team_namespace.go index a8328626..1b527cfc 100644 --- a/models/team_namespace.go +++ b/models/team_namespace.go @@ -3,9 +3,9 @@ package models // TeamNamespace defines the relationship between a Team and a Namespace type TeamNamespace struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - TeamID int64 `xorm:"int(11) not null" json:"team_id" param:"team"` - NamespaceID int64 `xorm:"int(11) not null" json:"namespace_id" param:"namespace"` - Right TeamRight `xorm:"int(11)" json:"right"` + TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"` + NamespaceID int64 `xorm:"int(11) not null INDEX" json:"namespace_id" param:"namespace"` + Right TeamRight `xorm:"int(11) INDEX" json:"right"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` diff --git a/models/teams.go b/models/teams.go index d28f6240..44f837d8 100644 --- a/models/teams.go +++ b/models/teams.go @@ -5,7 +5,7 @@ type Team struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"team"` Name string `xorm:"varchar(250) not null" json:"name"` Description string `xorm:"varchar(250)" json:"description"` - CreatedByID int64 `xorm:"int(11) not null" json:"-"` + CreatedByID int64 `xorm:"int(11) not null INDEX" json:"-"` CreatedBy User `xorm:"-" json:"created_by"` Members []*TeamUser `xorm:"-" json:"members"` @@ -38,9 +38,9 @@ func (t *Team) AfterLoad() { // TeamMember defines the relationship between a user and a team type TeamMember struct { ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - TeamID int64 `xorm:"int(11) not null" json:"team_id" param:"team"` - UserID int64 `xorm:"int(11) not null" json:"user_id" param:"user"` - Admin bool `xorm:"tinyint(1)" json:"admin"` + TeamID int64 `xorm:"int(11) not null INDEX" json:"team_id" param:"team"` + UserID int64 `xorm:"int(11) not null INDEX" json:"user_id" param:"user"` + Admin bool `xorm:"tinyint(1) INDEX" json:"admin"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"`