package dao

import (
	"fmt"
	"gorm.io/gorm"
	"iot_manager_service/util/common"
)

var Db *gorm.DB

func InitDB(db *gorm.DB) {
	Db = db
	models := []common.TableModelAuto{
		{&AkeyAlarmRecord{}, "一键求助记录表"},
	}
	for _, val := range models {
		//fmt.Println(val.Model)
		err := Db.Set("gorm:table_options", "comment '"+val.Comment+"'").AutoMigrate(val.Model)
		if err != nil {
			panic(fmt.Sprintf("AutoMigrate err : %v", err))
		}
	}
}
