Lee-WineList/initialize/db_table.go

25 lines
585 B
Go

package initialize
import (
"Lee-WineList/client"
"Lee-WineList/model/entity"
"git.echol.cn/loser/logger/log"
)
// 初始化数据库表
func databaseTable() {
dbs := []any{
new(entity.User), // 普通用户
new(entity.OAuth2Client), // OAuth2客户端
new(entity.Wine), // 酒单
new(entity.Material), // 酒单材料
new(entity.LikeWine), // 喜欢的酒单
}
if err := client.MySQL.AutoMigrate(dbs...); err != nil {
log.Panicf("数据库表预初始化处理:%s", err.Error())
}
log.Debugf("数据库表预初始化处理完成")
}