fix(数据库): 修复默认分组缺失与迁移锁阻塞

通过迁移补种默认 groups 记录,避免新装空分组
迁移锁改为 try lock + 重试并加入超时
写入 usage_logs 时保留 rate_multiplier=0 语义
测试: go test ./...
This commit is contained in:
yangjianbo
2025-12-29 10:43:46 +08:00
parent 3d617de577
commit 3a7d3387e0
5 changed files with 29 additions and 9 deletions

View File

@@ -260,7 +260,9 @@ func initializeDatabase(cfg *SetupConfig) error {
}
}()
return infrastructure.ApplyMigrations(context.Background(), db)
migrationCtx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
return infrastructure.ApplyMigrations(migrationCtx, db)
}
func createAdminUser(cfg *SetupConfig) error {