-- Migration 017: Fix project_archives embedding dimension
-- Changes vector(1536) to vector(1024) to match mxbai-embed-large model

-- Drop existing index first
DROP INDEX IF EXISTS idx_archives_embedding;

-- Alter the embedding column dimension
ALTER TABLE project_archives
    ALTER COLUMN embedding TYPE vector(1024);

-- Recreate index with correct dimension
CREATE INDEX idx_archives_embedding ON project_archives
    USING hnsw (embedding vector_cosine_ops);

-- Record migration
INSERT INTO schema_migrations (version) VALUES ('017_fix_archives_embedding_dimension')
ON CONFLICT (version) DO NOTHING;
