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