fix: add backward compatibility for Qdrant legacy collection detection

Implement intelligent legacy collection detection to support multiple
naming patterns from older LightRAG versions:
1. lightrag_vdb_{namespace} - Current legacy format
2. {workspace}_{namespace} - Old format with workspace
3. {namespace} - Old format without workspace

This ensures users can seamlessly upgrade from any previous version
without manual data migration.

Also add comprehensive test coverage for all migration scenarios:
- Case 1: Both new and legacy exist (warning)
- Case 2: Only new exists (already migrated)
- Backward compatibility with old workspace naming
- Backward compatibility with no-workspace naming
- Empty legacy collection handling
- Workspace isolation verification
- Model switching scenario

Testing:
- All 15 migration tests pass
- No breaking changes to existing tests
- Verified with: pytest tests/test_*migration*.py -v
This commit is contained in:
BukeLy 2025-11-20 01:43:47 +08:00
parent 3979095bae
commit df7a8f2a1c

View file

@ -13,12 +13,10 @@ Tests are implemented for both PostgreSQL and Qdrant backends.
""" """
import pytest import pytest
import asyncio
import numpy as np import numpy as np
from unittest.mock import MagicMock, patch, AsyncMock from unittest.mock import MagicMock, patch, AsyncMock
from lightrag.utils import EmbeddingFunc from lightrag.utils import EmbeddingFunc
from lightrag.kg.qdrant_impl import QdrantVectorDBStorage, _find_legacy_collection from lightrag.kg.qdrant_impl import QdrantVectorDBStorage, _find_legacy_collection
from lightrag.kg.postgres_impl import PGVectorStorage
# ============================================================================ # ============================================================================