common.go 805 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package dao
  2. import (
  3. "fmt"
  4. _ "github.com/go-sql-driver/mysql"
  5. "github.com/jinzhu/gorm"
  6. "iot_manager_service/app/system/dao"
  7. )
  8. var Db *gorm.DB
  9. func InitDB(db *gorm.DB) {
  10. Db = db
  11. err := Db.AutoMigrate(
  12. &dao.User{},
  13. &Dict{},
  14. &LampPoleGroup{},
  15. &LampPole{},
  16. &Gateway{},
  17. &GatewayRelation{},
  18. &Transformer{},
  19. &LightControl{},
  20. &Garbage{},
  21. &GarbageWayGroup{},
  22. &OnDemandGroup{},
  23. &OnDemandSensor{},
  24. &Zigbee{},
  25. &CameraDevice{},
  26. &InfoBoard{},
  27. &Alarm{},
  28. &CaptureUint{},
  29. &CheckPoint{},
  30. &AlarmTerminal{},
  31. &Bridge{},
  32. &BridgeSensor{},
  33. &IpBroadcast{},
  34. &ManholeCover{},
  35. &OptoSensor{},
  36. &IntelligentLight{},
  37. &TimeCondition{},
  38. &LightStrategy{},
  39. &LightCondition{},
  40. &DeviceVendor{},
  41. ).Error
  42. if err != nil {
  43. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  44. }
  45. }