Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ system:
router-prefix: ""
# 严格角色模式 打开后权限将会存在上下级关系
use-strict-auth: false
# 自动迁移数据库表结构,生产环境建议设为false,手动迁移
auto-migrate: false

# captcha configuration
captcha:
Expand Down
1 change: 1 addition & 0 deletions server/config/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ type System struct {
UseRedis bool `mapstructure:"use-redis" json:"use-redis" yaml:"use-redis"` // 使用redis
UseMongo bool `mapstructure:"use-mongo" json:"use-mongo" yaml:"use-mongo"` // 使用mongo
UseStrictAuth bool `mapstructure:"use-strict-auth" json:"use-strict-auth" yaml:"use-strict-auth"` // 使用树形角色分配模式
AutoMigrate bool `mapstructure:"auto-migrate" json:"auto-migrate" yaml:"auto-migrate"` // 自动迁移数据库表结构,生产环境建议设为false,手动迁移
}
5 changes: 5 additions & 0 deletions server/initialize/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ func Gorm() *gorm.DB {
}

func RegisterTables() {
if !global.GVA_CONFIG.System.AutoMigrate {
global.GVA_LOG.Info("auto-migrate is disabled, skipping table registration")
return
}

db := global.GVA_DB
err := db.AutoMigrate(

Expand Down