refactor: привести кодовую базу в соответствие с канонами bible

- 400 → 422 для всех ошибок валидации входных данных (handlers: export, quote, sync, vendor_spec, partnumber_books, pricelist)
- SQL-запросы вынесены из handlers в localdb (partnumber_books, pricelist, support_bundle); ValidateMariaDBConnection перенесён в internal/db/validate.go
- List-ответы унифицированы: ключ items, поля total_count/page/per_page/total_pages (component, pricelist, partnumber_books); шаблоны обновлены
- Молчаливые ошибки заменены на slog.Warn/Error (support_bundle, vendor_spec, component, configuration, local_configuration, localdb)
- N+1 запросы устранены: batch-запросы в export.go и vendor_workspace_import.go
- fmt.Println → slog в cmd/ (qfs, migrate, migrate_ops_projects, migrate_project_updated_at)
- Заголовки recovery/verify добавлены во все 28 SQL-миграций
- Добавлены bible-local/runtime-flows.md и bible-local/decisions/
- Обновлён субмодуль bible до v0.2.0-13

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 14:38:01 +03:00
parent e548305396
commit 184f54b663
59 changed files with 1164 additions and 196 deletions

View File

@@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"log"
"log/slog"
"os"
"regexp"
"sort"
@@ -79,12 +80,12 @@ func main() {
printPlan(actions)
if len(actions) == 0 {
fmt.Println("Nothing to migrate.")
slog.Info("Nothing to migrate.")
return
}
if !*apply {
fmt.Println("\nPreview complete. Re-run with -apply to execute.")
slog.Info("Preview complete. Re-run with -apply to execute.")
return
}
@@ -94,7 +95,7 @@ func main() {
log.Fatalf("confirmation failed: %v", confirmErr)
}
if !ok {
fmt.Println("Aborted.")
slog.Info("Aborted.")
return
}
}
@@ -103,7 +104,7 @@ func main() {
log.Fatalf("migration failed: %v", err)
}
fmt.Println("Migration completed successfully.")
slog.Info("Migration completed successfully.")
}
func ensureProjectsTable(db *gorm.DB) error {
@@ -212,10 +213,8 @@ func printPlan(actions []migrationAction) {
}
}
fmt.Printf("Planned actions: %d\n", len(actions))
fmt.Printf("Projects to create: %d\n", createCount)
fmt.Printf("Projects to reactivate: %d\n", reactivateCount)
fmt.Println("\nDetails:")
slog.Info("Plan summary", "actions", len(actions), "create", createCount, "reactivate", reactivateCount)
slog.Info("Details:")
for _, a := range actions {
extra := ""