File tree Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Expand file tree Collapse file tree 3 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,8 @@ system:
87
87
router-prefix : " "
88
88
# 严格角色模式 打开后权限将会存在上下级关系
89
89
use-strict-auth : false
90
+ # 自动迁移数据库表结构,生产环境建议设为false,手动迁移
91
+ auto-migrate : false
90
92
91
93
# captcha configuration
92
94
captcha :
Original file line number Diff line number Diff line change @@ -11,4 +11,5 @@ type System struct {
11
11
UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 使用redis
12
12
UseMongo bool `mapstructure:"use-mongo" json:"use-mongo" yaml:"use-mongo"` // 使用mongo
13
13
UseStrictAuth bool `mapstructure:"use-strict-auth" json:"use-strict-auth" yaml:"use-strict-auth"` // 使用树形角色分配模式
14
+ AutoMigrate bool `mapstructure:"auto-migrate" json:"auto-migrate" yaml:"auto-migrate"` // 自动迁移数据库表结构,生产环境建议设为false,手动迁移
14
15
}
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ func Gorm() *gorm.DB {
35
35
}
36
36
37
37
func RegisterTables () {
38
+ if ! global .GVA_CONFIG .System .AutoMigrate {
39
+ global .GVA_LOG .Info ("auto-migrate is disabled, skipping table registration" )
40
+ return
41
+ }
42
+
38
43
db := global .GVA_DB
39
44
err := db .AutoMigrate (
40
45
You can’t perform that action at this time.
0 commit comments