package dao import ( "fmt" "github.com/jinzhu/gorm" ) var Db *gorm.DB func InitDB(db *gorm.DB) { Db = db err := Db.AutoMigrate( &LampPoleGroup{}, &LampPole{}, &Gateway{}, &GatewayRelation{}, &Transformer{}, &LightControl{}, &Garbage{}, &GarbageWayGroup{}, &OnDemandGroup{}, &OnDemandSensor{}, &Zigbee{}, &CameraDevice{}, &InfoBoard{}, &Alarm{}, &CaptureUnit{}, &CheckPoint{}, &AlarmTerminal{}, &Bridge{}, &BridgeSensor{}, &IpBroadcast{}, &ManholeCover{}, &OptoSensor{}, &SwitchBox{}, &IntelligentLight{}, &TimeCondition{}, &LightStrategy{}, &LightCondition{}, &DeviceVendor{}, ).Error if err != nil { panic(fmt.Sprintf("AutoMigrate err : %v", err)) } }