migration.go 741 B

123456789101112131415161718192021222324252627282930313233343536
  1. package db
  2. import (
  3. "go.uber.org/zap"
  4. "cold-delivery/app/admin/model"
  5. jobModel "cold-delivery/app/jobs/model"
  6. )
  7. // 执行数据迁移
  8. func AutoMigrateDB() {
  9. //自动迁移模式
  10. err := DB.Set("gorm:table_options", "charset=utf8mb4").
  11. AutoMigrate(
  12. &jobModel.SysJob{},
  13. &model.SysUser{},
  14. //&model.SysRole{},
  15. //&model.SysRoleMenu{},
  16. //&model.SysMenu{},
  17. &model.SysDept{},
  18. &model.SysLoginLog{},
  19. &model.SysOperaLog{},
  20. &model.Address{},
  21. &model.AddressDefault{},
  22. &model.CoolerBox{},
  23. &model.Waybill{},
  24. &model.WaybillLogistics{},
  25. &model.WaybillTask{},
  26. &model.IceRaft{},
  27. &model.IceLocker{},
  28. &model.IceRaftRecord{},
  29. )
  30. if err != nil {
  31. zap.L().Panic("migrate db fail", zap.Error(err))
  32. }
  33. }