feat:完善项目信息
This commit is contained in:
@ -4,6 +4,7 @@ import (
|
||||
config2 "SciencesServer/app/basic/config"
|
||||
"SciencesServer/app/common/model"
|
||||
"SciencesServer/utils"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -22,12 +23,16 @@ type synchronized struct {
|
||||
func (this *Instance) Handle() {
|
||||
db := this.gormDB
|
||||
|
||||
successCount, failureCount := 0, 0
|
||||
|
||||
function := func(synchronized ...*synchronized) {
|
||||
for _, v := range synchronized {
|
||||
if !db.Migrator().HasTable(v.iModel) {
|
||||
err := db.Migrator().CreateTable(v.iModel)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
successCount++
|
||||
} else {
|
||||
failureCount++
|
||||
}
|
||||
if v.iValues != nil && v.iValues() != nil {
|
||||
db.Table(v.iModel.TableName()).Create(v.iValues())
|
||||
@ -136,6 +141,7 @@ func (this *Instance) Handle() {
|
||||
&synchronized{iModel: model.NewActivityInstance()}, &synchronized{iModel: model.NewActivityApply()},
|
||||
&synchronized{iModel: model.NewActivityExamine()}, &synchronized{iModel: model.NewActivityJoin()},
|
||||
)
|
||||
fmt.Printf("========================\n=== 数据迁移,成功【%d】,失败【%d】 ===\n========================\n", successCount, failureCount)
|
||||
}
|
||||
|
||||
func WithGormDBOption(db *gorm.DB) Option {
|
||||
|
Reference in New Issue
Block a user