mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 15:30:55 +00:00
orm fix create index
This commit is contained in:
parent
7c72b2dca7
commit
6686d9235c
@ -178,7 +178,7 @@ func getDbCreateSql(al *alias) (sqls []string, tableIndexes map[string][]string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, names := range sqlIndexes {
|
for _, names := range sqlIndexes {
|
||||||
name := strings.Join(names, "_")
|
name := mi.table + "_" + strings.Join(names, "_")
|
||||||
cols := strings.Join(names, sep)
|
cols := strings.Join(names, sep)
|
||||||
sql := fmt.Sprintf("CREATE INDEX %s%s%s ON %s%s%s (%s%s%s);", Q, name, Q, Q, mi.table, Q, Q, cols, Q)
|
sql := fmt.Sprintf("CREATE INDEX %s%s%s ON %s%s%s (%s%s%s);", Q, name, Q, Q, mi.table, Q, Q, cols, Q)
|
||||||
tableIndexes[mi.table] = append(tableIndexes[mi.table], sql)
|
tableIndexes[mi.table] = append(tableIndexes[mi.table], sql)
|
||||||
|
@ -81,6 +81,7 @@ type User struct {
|
|||||||
func (u *User) TableIndex() [][]string {
|
func (u *User) TableIndex() [][]string {
|
||||||
return [][]string{
|
return [][]string{
|
||||||
[]string{"Id", "UserName"},
|
[]string{"Id", "UserName"},
|
||||||
|
[]string{"Id", "Created"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +122,12 @@ type Post struct {
|
|||||||
Tags []*Tag `orm:"rel(m2m)"`
|
Tags []*Tag `orm:"rel(m2m)"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *Post) TableIndex() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"Id", "Created"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewPost() *Post {
|
func NewPost() *Post {
|
||||||
obj := new(Post)
|
obj := new(Post)
|
||||||
return obj
|
return obj
|
||||||
|
Loading…
Reference in New Issue
Block a user