package dao

import (
	"fmt"
	"gorm.io/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{},
		&TenantCode{},
	)
	if err != nil {
		panic(fmt.Sprintf("AutoMigrate err : %v", err))
	}
}
