common.go 313 B

1234567891011121314151617181920212223
  1. package dao
  2. import (
  3. "fmt"
  4. _ "github.com/go-sql-driver/mysql"
  5. "github.com/jinzhu/gorm"
  6. )
  7. var Db *gorm.DB
  8. func InitDB(db *gorm.DB) {
  9. Db = db
  10. err := Db.AutoMigrate(
  11. &User{},
  12. &Tenant{},
  13. &Role{},
  14. &RoleMenu{},
  15. &Menu{},
  16. ).Error
  17. if err != nil {
  18. panic(fmt.Sprintf("AutoMigrate err : %v", err))
  19. }
  20. }