package dao import ( "fmt" "github.com/jinzhu/gorm" ) var Db *gorm.DB func InitDB(db *gorm.DB) { Db = db err := Db.AutoMigrate( &User{}, &Dict{}, &Tenant{}, &Role{}, &RoleMenu{}, &Menu{}, &OperationHistory{}, ).Error if err != nil { panic(fmt.Sprintf("AutoMigrate err : %v", err)) } }