12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 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{},
- &CaptureUint{},
- &CheckPoint{},
- &AlarmTerminal{},
- &Bridge{},
- &BridgeSensor{},
- &IpBroadcast{},
- &ManholeCover{},
- &OptoSensor{},
- ).Error
- if err != nil {
- panic(fmt.Sprintf("AutoMigrate err : %v", err))
- }
- }
|