1234567891011121314151617181920 |
- package dao
- import (
- "fmt"
- "github.com/jinzhu/gorm"
- )
- var Db *gorm.DB
- func InitDB(db *gorm.DB) {
- Db = db
- err := Db.AutoMigrate(
- &Library{},
- &Program{},
- &ProgramRelation{},
- ).Error
- if err != nil {
- panic(fmt.Sprintf("AutoMigrate err : %v", err))
- }
- }
|