claude-os/migrations/add_slug_column.sql
Bob Roberts 53295444de Major refactor: Native Ollama setup + MCP integration
Features:
- Fixed Ollama configuration for native (localhost) instead of Docker
- Increased LLM timeout from 30s to 120s for quality answers
- Implemented KB slug system for clean MCP endpoint URLs
- Added multiple knowledge base support with type metadata
- Integrated MCP server with FastAPI (port 8051)
- React frontend with KB management UI
- PostgreSQL + pgvector for vector embeddings

Performance:
- 33-56% faster than Docker setup with native Ollama
- Direct Metal GPU acceleration on Apple Silicon
- Optimized RAG engine with caching
- ~40s response time for comprehensive answers

Documentation:
- Complete native setup guide (README_NATIVE_SETUP.md)
- Performance benchmarking and comparison
- MCP endpoint documentation
- Slug implementation details
- Decision rationale for native vs Docker

Cleanup:
- Removed old Streamlit setup files
- Consolidated setup scripts to single setup_native.sh
- Consolidated service management scripts
- Removed test artifacts and old analysis docs
- Ready for sharing with team

🚀 Production-ready for local team deployment

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 18:37:19 -05:00

38 lines
1.1 KiB
SQL

-- Migration: Add slug column to knowledge_bases table
-- Date: 2025-10-24
-- Description: Adds a URL-friendly slug column for KB-specific MCP endpoints
-- Add slug column if it doesn't exist
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name = 'knowledge_bases' AND column_name = 'slug'
) THEN
ALTER TABLE knowledge_bases ADD COLUMN slug VARCHAR(255);
END IF;
END $$;
-- Generate slugs for existing KBs
UPDATE knowledge_bases
SET slug = LOWER(
REGEXP_REPLACE(
REGEXP_REPLACE(
REGEXP_REPLACE(name, '[^a-zA-Z0-9\s-]', '', 'g'),
'[\s_]+', '-', 'g'
),
'-+', '-', 'g'
)
)
WHERE slug IS NULL;
-- Make slug unique and not null
ALTER TABLE knowledge_bases ALTER COLUMN slug SET NOT NULL;
ALTER TABLE knowledge_bases ADD CONSTRAINT knowledge_bases_slug_unique UNIQUE (slug);
-- Create index for fast slug lookups
CREATE INDEX IF NOT EXISTS idx_kb_slug ON knowledge_bases(slug);
-- Verify migration
SELECT name, slug FROM knowledge_bases ORDER BY created_at;