feat(ops): add usage_logs partitioning check at deployment startup
Some checks failed
CI / test (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled

Add CheckUsageLogsPartitioning function that:
- Checks if usage_logs table is partitioned
- Warns with prominent banner if not partitioned and rows > 100K
- Provides actionable guidance for manual partition migration

This helps operators identify performance risks early and take
appropriate action before data volume causes issues.
This commit is contained in:
User
2026-04-16 22:11:15 +08:00
parent 64b971a3dc
commit eb5adbbae5
2 changed files with 56 additions and 1 deletions

View File

@@ -362,7 +362,13 @@ func initializeDatabase(cfg *SetupConfig) error {
migrationCtx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
return repository.ApplyMigrations(migrationCtx, db)
if err := repository.ApplyMigrations(migrationCtx, db); err != nil {
return err
}
// 检查 usage_logs 分区状态(仅在首次部署时提示)
repository.CheckUsageLogsPartitioning(migrationCtx, db)
return nil
}
func createAdminUser(cfg *SetupConfig) (bool, string, error) {