#!/usr/bin/env python3
"""
Quick test script to verify the converter fixes work for problematic collections
"""

from mongo_to_postgres_converter import MongoToPostgresConverter

def test_problematic_collections():
    print("🧪 Testing converter fixes for problematic collections...")
    
    postgres_config = {
        'host': 'localhost',
        'port': '5432',
        'database': 'rocketchat_test',
        'user': 'rocketchat_user',
        'password': 'password123'
    }
    
    converter = MongoToPostgresConverter(
        'db/database/62df06d44234d20001289144',
        postgres_config,
        debug_mode=True,
        debug_collections=['rocketchat_settings', 'rocketchat_room']
    )
    
    # Test just discovery and schema analysis
    print("\n1. Testing collection discovery...")
    converter.discover_collections()
    
    print("\n2. Testing schema analysis...")
    if 'rocketchat_settings' in converter.collections:
        settings_schema = converter.analyze_schema('rocketchat_settings', 10)
        print(f"Settings schema fields: {len(settings_schema)}")
        
        # Check specific problematic fields
        if 'packageValue' in settings_schema:
            packagevalue_info = settings_schema['packageValue']
            pg_type = converter._determine_postgres_type(packagevalue_info)
            print(f"packageValue types: {packagevalue_info['types']} -> PostgreSQL: {pg_type}")
            
    if 'rocketchat_room' in converter.collections:
        room_schema = converter.analyze_schema('rocketchat_room', 10)
        print(f"Room schema fields: {len(room_schema)}")
        
        # Check specific problematic fields
        if 'sysMes' in room_schema:
            sysmes_info = room_schema['sysMes']
            pg_type = converter._determine_postgres_type(sysmes_info)
            print(f"sysMes types: {sysmes_info['types']} -> PostgreSQL: {pg_type}")
    
    print("\n✅ Test completed - check the type mappings above!")

if __name__ == '__main__':
    test_problematic_collections() 