fix filters unique bug
This commit is contained in:
parent
47b46118cd
commit
cd27da75c3
5 changed files with 21 additions and 3 deletions
|
|
@ -6,11 +6,21 @@ import (
|
|||
"github.com/yaoapp/kun/utils"
|
||||
)
|
||||
|
||||
var name string
|
||||
var migrateCmd = &cobra.Command{
|
||||
Use: "migrate",
|
||||
Short: "更新数据结构",
|
||||
Long: `更新数据库结构`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
|
||||
if name != "" {
|
||||
mod, has := gou.Models[name]
|
||||
if has {
|
||||
mod.Migrate(true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Do Stuff Here
|
||||
for name, mod := range gou.Models {
|
||||
utils.Dump(name)
|
||||
|
|
@ -18,3 +28,7 @@ var migrateCmd = &cobra.Command{
|
|||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
migrateCmd.PersistentFlags().StringVarP(&name, "name", "n", "", "指定模型名称")
|
||||
}
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -34,4 +34,4 @@ require (
|
|||
|
||||
// go env -w GOPRIVATE=github.com/yaoapp/*
|
||||
|
||||
replace github.com/yaoapp/gou => ../gou // gou local
|
||||
// replace github.com/yaoapp/gou => ../gou // gou local
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -353,6 +353,8 @@ github.com/yaoapp/gou v0.0.0-20210928091159-86d1b2abd60f h1:H2aQcZe/SZCuJ7kXH9Ba
|
|||
github.com/yaoapp/gou v0.0.0-20210928091159-86d1b2abd60f/go.mod h1:KwCRZDnEKLCxUNgMQ2acU7WI5zpt5SGOt1sBKqNAiaE=
|
||||
github.com/yaoapp/gou v0.0.0-20210928091747-b713e6eeaced h1:VcAXZFcP9AZI8Ou0CucrSlZn1dadgQDeZO6AaxNaqhw=
|
||||
github.com/yaoapp/gou v0.0.0-20210928091747-b713e6eeaced/go.mod h1:KwCRZDnEKLCxUNgMQ2acU7WI5zpt5SGOt1sBKqNAiaE=
|
||||
github.com/yaoapp/gou v0.0.0-20210928160401-c3e8f1c2162c h1:LCT2RmkbuNht0hm9ed1VhEsQMI71tIS7x6RuR7NeIQc=
|
||||
github.com/yaoapp/gou v0.0.0-20210928160401-c3e8f1c2162c/go.mod h1:KwCRZDnEKLCxUNgMQ2acU7WI5zpt5SGOt1sBKqNAiaE=
|
||||
github.com/yaoapp/kun v0.6.1 h1:gbjP5wmAuJLe1RGZ2evH4rPCVWykf0iqbksaHikF/GI=
|
||||
github.com/yaoapp/kun v0.6.1/go.mod h1:igsTcWDnzpp0HtRN7sBP+XOEN2tzoC5hk2MyoPFs3xA=
|
||||
github.com/yaoapp/xun v0.5.2 h1:DedZ26FpcXfkLnPKXzJsrbVmpWDRx9adUo8AvOcNT+g=
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ func getDefaultFilters(name string) map[string]Filter {
|
|||
cmap[col].Index = true
|
||||
break
|
||||
case "unique":
|
||||
cmap[col].Unique = true
|
||||
if len(index.Columns) == 1 {
|
||||
cmap[col].Unique = true
|
||||
}
|
||||
break
|
||||
case "primary":
|
||||
cmap[col].Primary = true
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "用户",
|
||||
"table": {
|
||||
"name": "user",
|
||||
"name": "xiang_user",
|
||||
"comment": "用户表",
|
||||
"engine": "InnoDB"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue