aboutsummaryrefslogtreecommitdiff
path: root/internal/db/user.go
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-04-11 20:18:05 +0800
committerGitHub <noreply@github.com>2020-04-11 20:18:05 +0800
commit41f56ad05d12520bb90f91889fa979465d0b3d6b (patch)
tree1ec7bc62a427ec2da011e882c61f2bfe04adef37 /internal/db/user.go
parent76bb647d2437dbdea86ac1a0caf5d768ab924e18 (diff)
login_source: migrate to GORM and add tests (#6090)
* Use GORM in all write paths * Migrate to GORM * Fix lint errors * Use GORM to init table * dbutil: make writer detect error * Add more tests * Rename to clearTables * db: finish adding tests * osutil: add tests * Fix load source files path
Diffstat (limited to 'internal/db/user.go')
-rw-r--r--internal/db/user.go38
1 files changed, 19 insertions, 19 deletions
diff --git a/internal/db/user.go b/internal/db/user.go
index a61bb687..11697bc7 100644
--- a/internal/db/user.go
+++ b/internal/db/user.go
@@ -48,33 +48,33 @@ const (
// User represents the object of individual and member of organization.
type User struct {
ID int64
- LowerName string `xorm:"UNIQUE NOT NULL"`
- Name string `xorm:"UNIQUE NOT NULL"`
+ LowerName string `xorm:"UNIQUE NOT NULL" gorm:"UNIQUE"`
+ Name string `xorm:"UNIQUE NOT NULL" gorm:"NOT NULL"`
FullName string
// Email is the primary email address (to be used for communication)
- Email string `xorm:"NOT NULL"`
- Passwd string `xorm:"NOT NULL"`
+ Email string `xorm:"NOT NULL" gorm:"NOT NULL"`
+ Passwd string `xorm:"NOT NULL" gorm:"NOT NULL"`
LoginType LoginType
- LoginSource int64 `xorm:"NOT NULL DEFAULT 0"`
+ LoginSource int64 `xorm:"NOT NULL DEFAULT 0" gorm:"NOT NULL;DEFAULT:0"`
LoginName string
Type UserType
- OwnedOrgs []*User `xorm:"-" json:"-"`
- Orgs []*User `xorm:"-" json:"-"`
- Repos []*Repository `xorm:"-" json:"-"`
+ OwnedOrgs []*User `xorm:"-" gorm:"-" json:"-"`
+ Orgs []*User `xorm:"-" gorm:"-" json:"-"`
+ Repos []*Repository `xorm:"-" gorm:"-" json:"-"`
Location string
Website string
- Rands string `xorm:"VARCHAR(10)"`
- Salt string `xorm:"VARCHAR(10)"`
+ Rands string `xorm:"VARCHAR(10)" gorm:"TYPE:VARCHAR(10)"`
+ Salt string `xorm:"VARCHAR(10)" gorm:"TYPE:VARCHAR(10)"`
- Created time.Time `xorm:"-" json:"-"`
+ Created time.Time `xorm:"-" gorm:"-" json:"-"`
CreatedUnix int64
- Updated time.Time `xorm:"-" json:"-"`
+ Updated time.Time `xorm:"-" gorm:"-" json:"-"`
UpdatedUnix int64
// Remember visibility choice for convenience, true for private
LastRepoVisibility bool
- // Maximum repository creation limit, -1 means use gloabl default
- MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1"`
+ // Maximum repository creation limit, -1 means use global default
+ MaxRepoCreation int `xorm:"NOT NULL DEFAULT -1" gorm:"NOT NULL;DEFAULT:-1"`
// Permissions
IsActive bool // Activate primary email
@@ -84,13 +84,13 @@ type User struct {
ProhibitLogin bool
// Avatar
- Avatar string `xorm:"VARCHAR(2048) NOT NULL"`
- AvatarEmail string `xorm:"NOT NULL"`
+ Avatar string `xorm:"VARCHAR(2048) NOT NULL" gorm:"TYPE:VARCHAR(2048);NOT NULL"`
+ AvatarEmail string `xorm:"NOT NULL" gorm:"NOT NULL"`
UseCustomAvatar bool
// Counters
NumFollowers int
- NumFollowing int `xorm:"NOT NULL DEFAULT 0"`
+ NumFollowing int `xorm:"NOT NULL DEFAULT 0" gorm:"NOT NULL;DEFAULT:0"`
NumStars int
NumRepos int
@@ -98,8 +98,8 @@ type User struct {
Description string
NumTeams int
NumMembers int
- Teams []*Team `xorm:"-" json:"-"`
- Members []*User `xorm:"-" json:"-"`
+ Teams []*Team `xorm:"-" gorm:"-" json:"-"`
+ Members []*User `xorm:"-" gorm:"-" json:"-"`
}
func (u *User) BeforeInsert() {