common.go 266 B

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