2022-05-25 18:51:57 +08:00
|
|
|
package initialize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.echol.cn/loser/logger/log"
|
|
|
|
"online_code/client"
|
|
|
|
"online_code/models/entity"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 初始化数据库表
|
|
|
|
func databaseTable() {
|
|
|
|
dbs := []any{
|
2022-05-26 23:53:18 +08:00
|
|
|
new(entity.UserBasic),
|
2022-05-26 00:39:39 +08:00
|
|
|
new(entity.TestCase),
|
2022-05-26 23:53:18 +08:00
|
|
|
new(entity.CategoryBasic),
|
|
|
|
new(entity.ProblemCategory),
|
|
|
|
//new(entity.ProblemBasic),
|
|
|
|
//new(entity.SubmitBasic),
|
2022-05-25 18:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := client.MySQL.AutoMigrate(dbs...); err != nil {
|
|
|
|
log.Panicf("数据库表预初始化处理:%s", err.Error())
|
|
|
|
}
|
|
|
|
log.Debugf("数据库表预初始化处理完成")
|
|
|
|
}
|