12345678910111213141516171819202122 |
- 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 {
- err := Db.Set("gorm:table_options", "comment '"+val.Comment+"'").AutoMigrate(val.Model)
- if err != nil {
- panic(fmt.Sprintf("AutoMigrate err : %v", err))
- }
- }
- }
|