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:
8787 router-prefix : " "
8888 # 严格角色模式 打开后权限将会存在上下级关系
8989 use-strict-auth : false
90+ # 自动迁移数据库表结构,生产环境建议设为false,手动迁移
91+ auto-migrate : false
9092
9193# captcha configuration
9294captcha :
Original file line number Diff line number Diff line change @@ -11,4 +11,5 @@ type System struct {
1111 UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 使用redis
1212 UseMongo bool `mapstructure:"use-mongo" json:"use-mongo" yaml:"use-mongo"` // 使用mongo
1313 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,手动迁移
1415}
Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ func Gorm() *gorm.DB {
3535}
3636
3737func RegisterTables () {
38+ if ! global .GVA_CONFIG .System .AutoMigrate {
39+ global .GVA_LOG .Info ("auto-migrate is disabled, skipping table registration" )
40+ return
41+ }
42+
3843 db := global .GVA_DB
3944 err := db .AutoMigrate (
4045
You can’t perform that action at this time.
0 commit comments