1234567891011121314151617181920212223242526272829303132333435363738 |
- package db
- import (
- "go.uber.org/zap"
- "cold-delivery/app/admin/model"
- jobModel "cold-delivery/app/jobs/model"
- )
- // 执行数据迁移
- func AutoMigrateDB() {
- //自动迁移模式
- err := DB.Set("gorm:table_options", "charset=utf8mb4").
- AutoMigrate(
- &jobModel.SysJob{},
- &model.SysUser{},
- //&model.SysRole{},
- //&model.SysRoleMenu{},
- //&model.SysMenu{},
- &model.SysDept{},
- &model.SysLoginLog{},
- &model.SysOperaLog{},
- &model.Address{},
- &model.AddressDefault{},
- &model.CoolerBox{},
- &model.Waybill{},
- &model.WaybillLogistics{},
- &model.WaybillTask{},
- &model.IceRaft{},
- &model.IceLocker{},
- &model.IceRaftRecord{},
- &model.CoolerBoxRecord{},
- &model.Drug{},
- )
- if err != nil {
- zap.L().Panic("migrate db fail", zap.Error(err))
- }
- }
|