LightRAG/lightrag
BukeLy a8f5c9bd33 fix: migrate workspace data in PostgreSQL Case 1 to prevent data loss
Why this change is needed:
In multi-tenant deployments, when workspace A migrates first (creating
the new model-suffixed table), subsequent workspace B initialization
enters Case 1 (both tables exist). The original Case 1 logic only
checked if the legacy table was empty globally, without checking if
the current workspace had unmigrated data. This caused workspace B's
data to remain in the legacy table while the application queried the
new table, resulting in data loss for workspace B.

How it solves the problem:
1. Extracted migration logic into _pg_migrate_workspace_data() helper
   function to avoid code duplication
2. Modified Case 1 to check if current workspace has data in legacy
   table and migrate it if found
3. Both Case 1 and Case 4 now use the same migration helper, ensuring
   consistent behavior
4. After migration, only delete the current workspace's data from
   legacy table, preserving other workspaces' data

Impact:
- Prevents data loss in multi-tenant PostgreSQL deployments
- Maintains backward compatibility with single-tenant setups
- Reduces code duplication between Case 1 and Case 4

Testing:
All PostgreSQL migration tests pass (8/8)
2025-11-26 01:16:57 +08:00
..
api Bump API version to 0256 2025-11-18 23:15:31 +08:00
evaluation Update LLM cache migration docs and improve UX prompts 2025-11-08 23:48:19 +08:00
kg fix: migrate workspace data in PostgreSQL Case 1 to prevent data loss 2025-11-26 01:16:57 +08:00
llm Improve Bedrock error handling with retry logic and custom exceptions 2025-11-17 12:54:32 +08:00
tools Improve LightRAG initialization checker tool with better usage docs 2025-11-17 15:42:54 +08:00
__init__.py Bump core version to 1.4.9.9 and API to 0252 2025-11-08 11:27:26 +08:00
base.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
constants.py Refactor entity merging with unified attribute merge function 2025-10-27 00:04:17 +08:00
exceptions.py Auto-initialize pipeline status in LightRAG.initialize_storages() 2025-11-17 12:54:33 +08:00
lightrag.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
namespace.py Add entity/relation chunk tracking with configurable source ID limits 2025-10-20 15:24:15 +08:00
operate.py Adjust chunking parameters to match the default environment variable settings 2025-11-18 23:14:50 +08:00
prompt.py Fix typo in 'equipment' in prompt.py 2025-10-22 11:13:22 +08:00
rerank.py
types.py
utils.py style: fix lint issues (trailing whitespace and formatting) 2025-11-20 01:28:39 +08:00
utils_graph.py Improve entity merge logging by removing redundant message and fixing typo 2025-10-31 17:16:59 +08:00