common.go 269 B

1234567891011121314151617181920
  1. package dao
  2. import (
  3. "fmt"
  4. "gorm.io/gorm"
  5. )
  6. var Db *gorm.DB
  7. func InitDB(db *gorm.DB) {
  8. Db = db
  9. err := Db.AutoMigrate(
  10. &GarbageData{},
  11. &EnvironmentData{},
  12. &EnvironmentDataSummary{},
  13. )
  14. if err != nil {
  15. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  16. }
  17. }