gzdaniel commited on
Commit
99956a1
·
1 Parent(s): 09a047e

Remove buggy data migration function

Browse files
Files changed (1) hide show
  1. lightrag/kg/tidb_impl.py +3 -58
lightrag/kg/tidb_impl.py CHANGED
@@ -2,7 +2,7 @@ import asyncio
2
  import os
3
  from dataclasses import dataclass, field
4
  from typing import Any, Union, final
5
-
6
  import numpy as np
7
 
8
  from lightrag.types import KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphEdge
@@ -46,61 +46,8 @@ class TiDB:
46
 
47
  async def _migrate_timestamp_columns(self):
48
  """Migrate timestamp columns in tables to timezone-aware types, assuming original data is in UTC"""
49
- # Tables and columns that need migration
50
- tables_to_migrate = {
51
- "LIGHTRAG_GRAPH_NODES": ["createtime", "updatetime"],
52
- "LIGHTRAG_GRAPH_EDGES": ["createtime", "updatetime"],
53
- "LIGHTRAG_DOC_CHUNKS": ["createtime", "updatetime"],
54
- }
55
-
56
- for table_name, columns in tables_to_migrate.items():
57
- for column_name in columns:
58
- try:
59
- # Check if column exists
60
- check_column_sql = f"""
61
- SELECT COLUMN_NAME, DATA_TYPE, COLUMN_TYPE
62
- FROM INFORMATION_SCHEMA.COLUMNS
63
- WHERE TABLE_NAME = '{table_name}'
64
- AND COLUMN_NAME = '{column_name}'
65
- """
66
-
67
- column_info = await self.query(check_column_sql)
68
- if not column_info:
69
- logger.warning(
70
- f"Column {table_name}.{column_name} does not exist, skipping migration"
71
- )
72
- continue
73
-
74
- # Check column type
75
- data_type = column_info.get("DATA_TYPE", "").lower()
76
- column_type = column_info.get("COLUMN_TYPE", "").lower()
77
-
78
- # If already timestamp type, check if it contains timezone information
79
- if data_type == "timestamp" and "time zone" in column_type:
80
- logger.info(
81
- f"Column {table_name}.{column_name} is already a timezone-aware timestamp type, no migration needed"
82
- )
83
- continue
84
-
85
- # If datetime type, need to migrate to timestamp
86
- if data_type == "datetime" or (
87
- data_type == "timestamp" and "time zone" not in column_type
88
- ):
89
- logger.info(
90
- f"Migrating {table_name}.{column_name} to timestamp type"
91
- )
92
- migration_sql = f"""
93
- ALTER TABLE {table_name}
94
- MODIFY COLUMN {column_name} TIMESTAMP
95
- """
96
-
97
- await self.execute(migration_sql)
98
- logger.info(
99
- f"Successfully migrated {table_name}.{column_name} to timestamp type"
100
- )
101
- except Exception as e:
102
- # Log error but don't interrupt the process
103
- logger.warning(f"Failed to migrate {table_name}.{column_name}: {e}")
104
 
105
  async def check_tables(self):
106
  # First create all tables
@@ -311,8 +258,6 @@ class TiDBKVStorage(BaseKVStorage):
311
  d["__vector__"] = embeddings[i]
312
 
313
  # Get current time as UNIX timestamp
314
- import time
315
-
316
  current_time = int(time.time())
317
 
318
  merge_sql = SQL_TEMPLATES["upsert_chunk"]
 
2
  import os
3
  from dataclasses import dataclass, field
4
  from typing import Any, Union, final
5
+ import time
6
  import numpy as np
7
 
8
  from lightrag.types import KnowledgeGraph, KnowledgeGraphNode, KnowledgeGraphEdge
 
46
 
47
  async def _migrate_timestamp_columns(self):
48
  """Migrate timestamp columns in tables to timezone-aware types, assuming original data is in UTC"""
49
+ # Not implemented yet
50
+ pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  async def check_tables(self):
53
  # First create all tables
 
258
  d["__vector__"] = embeddings[i]
259
 
260
  # Get current time as UNIX timestamp
 
 
261
  current_time = int(time.time())
262
 
263
  merge_sql = SQL_TEMPLATES["upsert_chunk"]