Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
nfjBill committed Feb 18, 2022
1 parent 80a6f88 commit a5ae25f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions dm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type User struct {
Birthday time.Time
}

type Per struct {
type PerPel struct {
gorm.Model
Key string `gorm:"index:key,unique"`
Name string `gorm:"index:name"`
Expand All @@ -59,9 +59,9 @@ func TestAutoMigrate(t *testing.T) {
err = Table().AutoMigrate(&User{})
err = Table().AutoMigrate(&User{})
err = Table().AutoMigrate(&User{})
err = Table().AutoMigrate(&Per{})
err = Table().AutoMigrate(&Per{})
err = Table().AutoMigrate(&Per{})
err = Table().AutoMigrate(&PerPel{})
err = Table().AutoMigrate(&PerPel{})
err = Table().AutoMigrate(&PerPel{})

if err != nil {
fmt.Printf("Error: failed to AutoMigrate: %v\n", err)
Expand Down
6 changes: 3 additions & 3 deletions namer.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ func (n Namer) CheckerName(table, column string) (name string) {
}

func (n Namer) IndexName(table, column string) (name string) {
cl := n.NamingStrategy.IndexName(table, column)
ac := strings.Split(strings.ToLower(column), "idx")
tlc := strings.ToLower(column)

if len(ac) > 1 {
cl := n.NamingStrategy.IndexName(table, column)
if strings.Contains(tlc, "idx_"+strings.ToLower(table)) && strings.Contains(tlc, strings.ToLower(column)) {
cl = column
}

Expand Down

0 comments on commit a5ae25f

Please sign in to comment.