Addded drop to postgresql
Browse files- lightrag/kg/postgres_impl.py +13 -1
lightrag/kg/postgres_impl.py
CHANGED
|
@@ -301,7 +301,11 @@ class PGKVStorage(BaseKVStorage):
|
|
| 301 |
# PG handles persistence automatically
|
| 302 |
pass
|
| 303 |
|
| 304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
@final
|
| 306 |
@dataclass
|
| 307 |
class PGVectorStorage(BaseVectorStorage):
|
|
@@ -1194,4 +1198,12 @@ SQL_TEMPLATES = {
|
|
| 1194 |
FROM LIGHTRAG_DOC_CHUNKS where workspace=$1)
|
| 1195 |
WHERE distance>$2 ORDER BY distance DESC LIMIT $3
|
| 1196 |
""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1197 |
}
|
|
|
|
| 301 |
# PG handles persistence automatically
|
| 302 |
pass
|
| 303 |
|
| 304 |
+
async def drop(self) -> None:
|
| 305 |
+
"""Drop the storage"""
|
| 306 |
+
drop_sql = SQL_TEMPLATES["DROP_ALL"]
|
| 307 |
+
await self.db.execute(drop_sql)
|
| 308 |
+
|
| 309 |
@final
|
| 310 |
@dataclass
|
| 311 |
class PGVectorStorage(BaseVectorStorage):
|
|
|
|
| 1198 |
FROM LIGHTRAG_DOC_CHUNKS where workspace=$1)
|
| 1199 |
WHERE distance>$2 ORDER BY distance DESC LIMIT $3
|
| 1200 |
""",
|
| 1201 |
+
#DROP everything
|
| 1202 |
+
"drop": """
|
| 1203 |
+
DROP TABLE IF EXISTS LIGHTRAG_DOC_FULL CASCADE;
|
| 1204 |
+
DROP TABLE IF EXISTS LIGHTRAG_DOC_CHUNKS CASCADE;
|
| 1205 |
+
DROP TABLE IF EXISTS LIGHTRAG_LLM_CACHE CASCADE;
|
| 1206 |
+
DROP TABLE IF EXISTS LIGHTRAG_VDB_ENTITY CASCADE;
|
| 1207 |
+
DROP TABLE IF EXISTS LIGHTRAG_VDB_RELATION CASCADE;
|
| 1208 |
+
""",
|
| 1209 |
}
|