add: index about some tables

This commit is contained in:
yystopf 2022-04-27 18:08:42 +08:00
parent 082d59adae
commit 0ccfbe7a5d
5 changed files with 46 additions and 2 deletions

View File

@ -327,6 +327,10 @@ var migrations = []Migration{
NewMigration("Drop unneeded webhook related columns", dropWebhookColumns),
// v188 -> v189
NewMigration("Add key is verified to gpg key", addKeyIsVerified),
// v189 -> v190
NewMigration("Add index about user email", addIndexAboutUserEmail),
// v190 -> v191
NewMigration("Add index about access token last eight", addIndexAboutAccessTokenLastEight),
}
// GetCurrentDBVersion returns the current db version

20
models/migrations/v189.go Normal file
View File

@ -0,0 +1,20 @@
/*
* @Description: Do not edit
* @Date: 2022-04-27 17:58:22
* @LastEditors: viletyy
* @Author: viletyy
* @LastEditTime: 2022-04-27 18:04:33
* @FilePath: /gitea-1156/models/migrations/v189.go
*/
package migrations
import "xorm.io/xorm"
func addIndexAboutUserEmail(x *xorm.Engine) error {
type User struct {
Email string `xorm:"INDEX NOT NULL"`
}
return x.Sync2(new(User))
}

20
models/migrations/v190.go Normal file
View File

@ -0,0 +1,20 @@
/*
* @Description: Do not edit
* @Date: 2022-04-27 18:04:31
* @LastEditors: viletyy
* @Author: viletyy
* @LastEditTime: 2022-04-27 18:05:38
* @FilePath: /gitea-1156/models/migrations/v190.go
*/
package migrations
import "xorm.io/xorm"
func addIndexAboutAccessTokenLastEight(x *xorm.Engine) error {
type AccessToken struct {
TokenLastEight string `xorm:"INDEX token_last_eight"`
}
return x.Sync2(new(AccessToken))
}

View File

@ -24,7 +24,7 @@ type AccessToken struct {
Token string `xorm:"-"`
TokenHash string `xorm:"UNIQUE"` // sha256 of token
TokenSalt string
TokenLastEight string `xorm:"token_last_eight"`
TokenLastEight string `xorm:"INDEX token_last_eight"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`

View File

@ -97,7 +97,7 @@ type User struct {
Name string `xorm:"UNIQUE NOT NULL"`
FullName string
// Email is the primary email address (to be used for communication)
Email string `xorm:"NOT NULL"`
Email string `xorm:"INDEX NOT NULL"`
KeepEmailPrivate bool
EmailNotificationsPreference string `xorm:"VARCHAR(20) NOT NULL DEFAULT 'enabled'"`
Passwd string `xorm:"NOT NULL"`