#!/usr/bin/env python3
"""
Script to run PostgreSQL to Neo4j migration with TSS namespace
"""

import os
import sys

# Add src directory to path
sys.path.append('src')

from postgres_to_neo4j_migration import PostgresToNeo4jMigration

def run_migration():
    """Run the PostgreSQL to Neo4j migration"""
    try:
        # PostgreSQL configuration
        postgres_config = {
            'host': os.getenv('POSTGRES_HOST', 'localhost'),
            'port': int(os.getenv('POSTGRES_PORT', '5432')),
            'user': os.getenv('POSTGRES_USER', 'pipeline_admin'),
            'password': os.getenv('POSTGRES_PASSWORD', 'secure_pipeline_2024'),
            'database': os.getenv('POSTGRES_DB', 'dev_pipeline')
        }
        
        # Neo4j configuration
        neo4j_config = {
            'uri': os.getenv('NEO4J_URI', 'bolt://localhost:7687'),
            'user': os.getenv('NEO4J_USER', 'neo4j'),
            'password': os.getenv('NEO4J_PASSWORD', 'password')
        }
        
        # Run migration with TSS namespace
        migration = PostgresToNeo4jMigration(postgres_config, neo4j_config, namespace='TSS')
        success = migration.run_full_migration()
        
        if success:
            print('Migration completed successfully')
            return 0
        else:
            print('Migration failed')
            return 1
            
    except Exception as e:
        print(f'Migration error: {e}')
        return 1

if __name__ == '__main__':
    sys.exit(run_migration())
