go_gin_tmpl/initialize/db_table.go

20 lines
398 B
Go
Raw Normal View History

2022-05-09 09:00:14 +08:00
package initialize
import (
"ginDemo/client"
"ginDemo/model/entity"
"gitee.ltd/lxh/logger"
)
// 初始化数据库表
func databaseTable() {
dbs := []any{
new(entity.User), // 管理员用户
}
if err := client.MySQL.AutoMigrate(dbs...); err != nil {
logger.Say.Panicf("数据库表预初始化处理:%s", err.Error())
}
logger.Say.Debugf("数据库表预初始化处理完成")
}