Spaces:
Running
Running
File size: 806 Bytes
abc646e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | """Clear all entries with wrong user_id from document_metadata collection."""
from services.chroma_service import ChromaService
def clear_old_data():
print("Connecting to ChromaDB...")
c = ChromaService()
# Get all entries with the wrong user_id
data = c.metadata_collection.get(where={"user_id": "jashdoshi"})
count = len(data['ids'])
print(f"Found {count} entries with user_id='jashdoshi' (old migration)")
if count > 0 and data['ids']:
print("Deleting these entries...")
c.metadata_collection.delete(ids=data['ids'])
print(f"Deleted {count} entries.")
# Verify
remaining = c.metadata_collection.get()
print(f"Remaining entries in collection: {len(remaining['ids'])}")
if __name__ == "__main__":
clear_old_data()
|