#!/usr/bin/env python3 """ Test script to verify database migration works correctly """ import sys import os sys.path.append(os.path.dirname(os.path.abspath(__file__))) from utils.database_manager import get_database_manager, reset_database_manager import logging # Set up logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) def test_migration(): """Test the database migration""" try: logger.info("Testing database migration...") # Reset the database manager to force re-initialization reset_database_manager() # Get a new instance (this will trigger migration) db_manager = get_database_manager() # Test if we can access the input_features_blob column with db_manager._get_connection() as conn: cursor = conn.execute("PRAGMA table_info(inference_records)") columns = [row[1] for row in cursor.fetchall()] if 'input_features_blob' in columns: logger.info("✅ input_features_blob column exists - migration successful!") return True else: logger.error("❌ input_features_blob column missing - migration failed!") return False except Exception as e: logger.error(f"❌ Migration test failed: {e}") return False if __name__ == "__main__": success = test_migration() sys.exit(0 if success else 1)