1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package dao
- import (
- "fmt"
- _ "github.com/go-sql-driver/mysql"
- "github.com/jinzhu/gorm"
- "iot_manager_service/app/system/dao"
- )
- var Db *gorm.DB
- func InitDB(db *gorm.DB) {
- Db = db
- err := Db.AutoMigrate(
- &dao.User{},
- &Dict{},
- &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{},
- &OperationHis{},
- ).Error
- if err != nil {
- panic(fmt.Sprintf("AutoMigrate err : %v", err))
- }
- }
|