fix: 修复默认分组初始化导致启动失败的问题

- 标准版不再创建默认分组,简易模式保持创建
- 简易模式下删除默认分组后重启自动恢复(而非报唯一键冲突)
- AutoMigrate 函数增加 runMode 参数以区分运行模式
This commit is contained in:
shaw
2025-12-30 14:30:16 +08:00
parent 64b8219245
commit fb883f0092
4 changed files with 41 additions and 9 deletions

View File

@@ -30,7 +30,7 @@ func InitDB(cfg *config.Config) (*gorm.DB, error) {
// 自动迁移(始终执行,确保数据库结构与代码同步)
// GORM 的 AutoMigrate 只会添加新字段,不会删除或修改已有字段,是安全的
if err := repository.AutoMigrate(db); err != nil {
if err := repository.AutoMigrate(db, cfg.RunMode); err != nil {
return nil, err
}