#!/usr/bin/env python3 """Verify PostgreSQL port configuration is correct.""" import re from pathlib import Path def check_file(file_path: Path, pattern: str, should_match: bool, description: str) -> tuple[bool, str]: """Check if a file matches the expected pattern.""" try: content = file_path.read_text(encoding='utf-8', errors='ignore') matches = bool(re.search(pattern, content)) if matches == should_match: return True, f"āœ… {description}" else: return False, f"āŒ {description} - {'Found' if matches else 'Not found'} when {'should' if should_match else 'should not'} be present" except FileNotFoundError: return False, f"āŒ {description} - File not found" except Exception as e: return False, f"āŒ {description} - Error: {e}" def main(): """Verify port configuration.""" project_root = Path(__file__).parent.parent checks = [ # File, pattern, should_match, description (project_root / "docker-compose.yml", r'"5433:5432"', True, "docker-compose.yml maps port 5433:5432"), (project_root / "scripts" / "setup_env.py", r'localhost:5433.*audioforge', True, "setup_env.py uses port 5433 for development"), (project_root / "backend" / "app" / "core" / "config.py", r'localhost:5433.*audioforge', True, "config.py defaults to port 5433"), (project_root / "scripts" / "create_env_with_token.py", r'localhost:5433.*audioforge', True, "create_env_with_token.py uses port 5433"), ] print("\nšŸ” Verifying PostgreSQL Port Configuration\n") print("=" * 60) all_passed = True for file_path, pattern, should_match, description in checks: passed, message = check_file(file_path, pattern, should_match, description) print(message) if not passed: all_passed = False print("=" * 60) if all_passed: print("\nāœ… All port configurations are correct!") print("\nThe fix ensures:") print(" • Docker exposes PostgreSQL on port 5433") print(" • Development setup scripts use port 5433") print(" • Backend defaults to port 5433") return 0 else: print("\nāŒ Some configurations need fixing!") return 1 if __name__ == "__main__": exit(main())