liuxiaolong
2020-08-18 27f1012d2fecda7bcc3d9f44c5dd4c10a7cf38a4
models/db.go
@@ -1 +1,18 @@
package models
import (
   "car-service/extend/util"
   "github.com/astaxie/beego"
   "github.com/astaxie/beego/orm"
   _ "github.com/mattn/go-sqlite3"
)
func InitDb() {
   dbUrl := beego.AppConfig.String("dbUrl")
   rootPath := util.GetAppRootPath()
   dbPath := rootPath +"/"+ dbUrl
   orm.RegisterDriver("sqlite", orm.DRSqlite)
   _ = orm.RegisterDataBase("default", "sqlite3", dbPath)
   orm.RegisterModel(new(User), new(UserCar), new(SysUpgrade), new(UserClient), new(Restriction), new(Log))
   _ = orm.RunSyncdb("default", false, true)
}