Files

32 lines
517 B
Go

package global
import (
"gorm.io/gorm"
"work_cation/cfg"
"work_cation/models"
"work_cation/pkg/gormx"
"work_cation/repo"
)
var DB *gorm.DB
func InitDB() {
var err error
DB, err = gormx.New(gormx.Config{DSN: cfg.T.DbPath, Type: "sqlite3"})
if err != nil {
panic(err)
}
err = DB.AutoMigrate(
&models.ErlangCardCollections{},
&models.History{},
&models.Users{},
&models.UserFollows{},
&models.BaseCard{},
&models.ChatMessage{},
)
if err != nil {
panic(err)
}
repo.User.GetUserInfo(DB)
}