common.go 721 B

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