添加数据库数据初始化
This commit is contained in:
1 parent
6bb6c69700
commit
02255240fe
1 file changed
+12
-2
+12
-2
@@ -9,6 +9,7 @@ import (
|
||||
tools2 "go-admin/models/tools"
|
||||
"go-admin/tools"
|
||||
config2 "go-admin/tools/config"
|
||||
"log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -41,8 +42,17 @@ func run() {
|
||||
database.Setup()
|
||||
//4. 数据库迁移
|
||||
gorm.AutoMigrate(orm.Eloquent)
|
||||
//db := gdb.GetDB()
|
||||
//db.AutoMigrate(migrateModel()...)
|
||||
log.Println("数据库结构初始化成功!")
|
||||
//5. 数据初始化完成
|
||||
if config2.ApplicationConfig.IsInit {
|
||||
if err := models.InitDb(); err != nil {
|
||||
log.Fatal("数据库基础数据初始化失败!")
|
||||
} else {
|
||||
config2.SetApplicationIsInit()
|
||||
}
|
||||
log.Println("数据库基础数据初始化成功!")
|
||||
}
|
||||
|
||||
usage = `finish`
|
||||
fmt.Println(usage)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user