fix(text-cache): add missing model_version column to migration + strict git detection

- Create new migration 0001_add_model_version_to_cache.sql to add model_version column to text_analysis_cache table (default 'v1')
- Add composite index on source + model_version for efficient cache lookups
- Improve git branch detection in textCacheStore.ts:
  * Check CACHE_MODEL_VERSION env var first (required in Docker)
  * Suppress stderr with stdio pipes to eliminate spurious warnings
  * Log ERROR (not warning) when git unavailable AND no env var set
  * Only fall back to 'v1' as last resort, preventing silent dummy usage
- Remove unused imports (logModelVersionChange, logCacheInvalidation) and previousVersion variable
- Fixes repeated 'column model_version does not exist' errors on bot startup

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-06-02 12:46:37 +07:00
co-authored by Claude Opus 4.8
parent 505c30f124
commit 682fb31deb
2 changed files with 26 additions and 16 deletions
@@ -0,0 +1,6 @@
-- Add model_version column to text_analysis_cache table
ALTER TABLE "text_analysis_cache" ADD COLUMN "model_version" text DEFAULT 'v1' NOT NULL;
-- Create indexes for model_version and composite source+model_version
CREATE INDEX "idx_text_analysis_cache_model_version" ON "text_analysis_cache" USING btree ("model_version");
CREATE INDEX "idx_text_analysis_cache_source_model_version" ON "text_analysis_cache" USING btree ("source","model_version");