From f11900451a976b6822d7d31acf507b6218d35037 Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Tue, 18 Feb 2025 09:10:50 +0100 Subject: [PATCH] Addded drop to postgresql --- lightrag/kg/postgres_impl.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 16aee8b8..c4f13c62 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -301,7 +301,11 @@ class PGKVStorage(BaseKVStorage): # PG handles persistence automatically pass - + async def drop(self) -> None: + """Drop the storage""" + drop_sql = SQL_TEMPLATES["DROP_ALL"] + await self.db.execute(drop_sql) + @final @dataclass class PGVectorStorage(BaseVectorStorage): @@ -1194,4 +1198,12 @@ SQL_TEMPLATES = { FROM LIGHTRAG_DOC_CHUNKS where workspace=$1) WHERE distance>$2 ORDER BY distance DESC LIMIT $3 """, + #DROP everything + "drop": """ + DROP TABLE IF EXISTS LIGHTRAG_DOC_FULL CASCADE; + DROP TABLE IF EXISTS LIGHTRAG_DOC_CHUNKS CASCADE; + DROP TABLE IF EXISTS LIGHTRAG_LLM_CACHE CASCADE; + DROP TABLE IF EXISTS LIGHTRAG_VDB_ENTITY CASCADE; + DROP TABLE IF EXISTS LIGHTRAG_VDB_RELATION CASCADE; + """, }