Browse Source

fix unique key too long when use myisam

pull/5380/head
yinhao 6 years ago
parent
commit
1d80fe24e3
  1. 2
      models/login_source.go
  2. 6
      models/models.go
  3. 2
      models/repo.go
  4. 4
      models/repo_branch.go
  5. 4
      models/user.go
  6. 2
      models/user_mail.go

2
models/login_source.go

@ -131,7 +131,7 @@ func (f *AuthSourceFile) Save() error {
type LoginSource struct {
ID int64
Type LoginType
Name string `xorm:"UNIQUE"`
Name string `xorm:"varchar(191) UNIQUE"`
IsActived bool `xorm:"NOT NULL DEFAULT false"`
Cfg core.Conversion `xorm:"TEXT"`

6
models/models.go

@ -330,6 +330,7 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
rawTableName := x.TableName(table)
_, isInsertProcessor := table.(xorm.BeforeInsertProcessor)
scanner := bufio.NewScanner(f)
for scanner.Scan() {
switch bean := table.(type) {
case *LoginSource:
@ -367,10 +368,13 @@ func ImportDatabase(dirPath string, verbose bool) (err error) {
// Reset created_unix back to the date save in archive because Insert method updates its value
if isInsertProcessor && !skipInsertProcessors[rawTableName] {
if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", meta["CreatedUnix"], meta["ID"]); err != nil {
timestamp, ok := meta["CreatedUnix"].(uint64)
if ok {
if _, err = x.Exec("UPDATE "+rawTableName+" SET created_unix=? WHERE id=?", timestamp, meta["ID"]); err != nil {
log.Error(2, "Failed to reset 'created_unix': %v", err)
}
}
}
switch rawTableName {
case "milestone":

2
models/repo.go

@ -152,7 +152,7 @@ type Repository struct {
ID int64
OwnerID int64 `xorm:"UNIQUE(s)"`
Owner *User `xorm:"-" json:"-"`
LowerName string `xorm:"UNIQUE(s) INDEX NOT NULL"`
LowerName string `xorm:"varchar(191) UNIQUE(s) INDEX NOT NULL"`
Name string `xorm:"INDEX NOT NULL"`
Description string `xorm:"VARCHAR(512)"`
Website string

4
models/repo_branch.go

@ -70,7 +70,7 @@ type ProtectBranchWhitelist struct {
ID int64
ProtectBranchID int64
RepoID int64 `xorm:"UNIQUE(protect_branch_whitelist)"`
Name string `xorm:"UNIQUE(protect_branch_whitelist)"`
Name string `xorm:"varchar(191) UNIQUE(protect_branch_whitelist)"`
UserID int64 `xorm:"UNIQUE(protect_branch_whitelist)"`
}
@ -84,7 +84,7 @@ func IsUserInProtectBranchWhitelist(repoID, userID int64, branch string) bool {
type ProtectBranch struct {
ID int64
RepoID int64 `xorm:"UNIQUE(protect_branch)"`
Name string `xorm:"UNIQUE(protect_branch)"`
Name string `xorm:"varchar(191) UNIQUE(protect_branch)"`
Protected bool
RequirePullRequest bool
EnableWhitelist bool

4
models/user.go

@ -48,8 +48,8 @@ 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:"varchar(191) UNIQUE NOT NULL"`
Name string `xorm:"varchar(191) UNIQUE NOT NULL"`
FullName string
// Email is the primary email address (to be used for communication)
Email string `xorm:"NOT NULL"`

2
models/user_mail.go

@ -16,7 +16,7 @@ import (
type EmailAddress struct {
ID int64
UID int64 `xorm:"INDEX NOT NULL"`
Email string `xorm:"UNIQUE NOT NULL"`
Email string `xorm:"varchar(191) UNIQUE NOT NULL"`
IsActivated bool
IsPrimary bool `xorm:"-" json:"-"`
}

Loading…
Cancel
Save