"""
Test ChromaDB upgrade with SQLite fix
"""

# Apply SQLite fix BEFORE importing ChromaDB
import chromadb_sqlite_fix

# Now test ChromaDB
import chromadb
print(f"\nChromaDB version: {chromadb.__version__}")

# Test creating client
client = chromadb.Client()
print("✅ ChromaDB client created successfully!")

# Test creating collection
collection = client.create_collection("test_upgrade")
print("✅ Collection created successfully!")

# Test adding document
collection.add(
    documents=["Test document"],
    ids=["test1"]
)
print("✅ Document added successfully!")

# Test MCP compatibility
print("\nTesting MCP compatibility...")
try:
    # Test the methods MCP server needs
    collections = client.list_collections()
    print(f"✅ list_collections works: {len(collections)} collections")
    
    # Test get_or_create_collection
    col2 = client.get_or_create_collection("test_mcp")
    print("✅ get_or_create_collection works")
    
    # Clean up
    client.delete_collection("test_upgrade")
    client.delete_collection("test_mcp")
    print("✅ delete_collection works")
    
    print("\n✨ ChromaDB 0.4.24 is compatible with MCP server!")
    
except Exception as e:
    print(f"❌ MCP compatibility issue: {e}")