-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate.go
59 lines (48 loc) · 928 Bytes
/
migrate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package migrate
import (
"github.com/isjyi/os/models"
"gorm.io/gorm"
)
func AutoMigrate(db *gorm.DB) error {
err := db.AutoMigrate(&models.SysUser{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysRole{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.Casbin{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysSetting{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysRole{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysRoleMenu{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.Menu{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysDictType{})
if err != nil {
return err
}
err = db.AutoMigrate(&models.SysDictData{})
if err != nil {
return err
}
// models.DataInit()
return err
}
func CustomMigrate(db *gorm.DB, table interface{}) error {
return db.AutoMigrate(&table)
}