mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-25 21:40:13 +00:00
acf4e225e6
Complete rewrite of the Hermes SQLite database schema synchronization mechanism with comprehensive error handling, automatic recovery, and full test coverage. ## Database Schema Synchronization - **Unified sync mechanism**: Single `syncTable()` function handles all schema changes - **Automatic column sync**: Adds missing columns and removes extra columns - **Table rebuilding**: Automatically rebuilds tables when primary keys or types change - **Data preservation**: Preserves data during schema changes when compatible - **Index management**: Creates and removes indexes as needed ## Error Recovery & Reliability - **Automatic backup**: Backs up corrupted database before recovery - **Retry limiting**: Prevents infinite loops with retry limit - **Duplicate prevention**: Avoids multiple backup files - **Safe file operations**: Uses copy+delete instead of rename for safety ## Composite Primary Keys - Fixed GC_ROOM_AGENTS and GC_ROOM_MEMBERS with proper composite primary keys - Prevents duplicate entries while allowing same roomId with different agentId/userId ## Test Coverage - **10 new integration tests** for schema synchronization (tests/server/schema-sync.test.ts) - **3 updated tests** for Hermes schemas (tests/server/hermes-schemas.test.ts) - All 327 tests passing (47 test files, 325 passed, 2 skipped) ## Bug Fixes - Fixed module import issues (unified ES6 imports, removed mixed require()) - Fixed mock issues in sessions routes tests - Fixed i18n coverage test to handle newly added keys - Fixed profiles store test to match current implementation Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>