File size: 4,183 Bytes
e697769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python3
"""
Database Implementation Verification Script
Validates that all Neon database components are correctly installed
"""

import sys
from pathlib import Path

# Add backend to path
backend_dir = Path(__file__).parent.parent
sys.path.insert(0, str(backend_dir))

print("=" * 70)
print("NEON POSTGRES DATABASE - IMPLEMENTATION VERIFICATION")
print("=" * 70)

# Test 1: Import database connection
print("\n[1/6] Testing database connection imports...")
try:
    from app.database import db, get_db, lifespan_manager, Base
    print("βœ“ Database connection manager imported")
except ImportError as e:
    print(f"βœ— Failed to import database connection: {e}")
    sys.exit(1)

# Test 2: Import all models
print("\n[2/6] Testing model imports...")
try:
    from app.database.models import (
        User, Organization, UserProfile, Role, UserRole,
        Assessment, PipelineStage, BiomarkerValue,
        RetinalResult, SpeechResult, CardiologyResult,
        RadiologyResult, DermatologyResult, CognitiveResult,
        ChatThread, ChatMessage, AIExplanation,
        UploadedFile, AuditEvent
    )
    model_count = 17
    print(f"βœ“ All {model_count} models imported successfully")
except ImportError as e:
    print(f"βœ— Failed to import models: {e}")
    sys.exit(1)

# Test 3: Import repository
print("\n[3/6] Testing repository imports...")
try:
    from app.database.repositories import AssessmentRepository
    print("βœ“ Assessment repository imported")
except ImportError as e:
    print(f"βœ— Failed to import repository: {e}")
    sys.exit(1)

# Test 4: Check dependencies
print("\n[4/6] Checking dependencies...")
try:
    import alembic
    print(f"βœ“ Alembic {alembic.__version__} installed")
except ImportError:
    print("βœ— Alembic not installed")
    sys.exit(1)

try:
    import asyncpg
    print(f"βœ“ asyncpg {asyncpg.__version__} installed")
except ImportError:
    print("βœ— asyncpg not installed")
    sys.exit(1)

try:
    import tenacity
    print(f"βœ“ tenacity {tenacity.__version__} installed")
except ImportError:
    print("βœ— tenacity not installed")
    sys.exit(1)

# Test 5: Check Alembic configuration
print("\n[5/6] Checking Alembic configuration...")
alembic_ini = backend_dir / "alembic.ini"
migrations_env = backend_dir / "migrations" / "env.py"

if alembic_ini.exists():
    print("βœ“ alembic.ini found")
else:
    print("βœ— alembic.ini missing")
    sys.exit(1)

if migrations_env.exists():
    print("βœ“ migrations/env.py found")
else:
    print("βœ— migrations/env.py missing")
    sys.exit(1)

# Test 6: Check environment configuration
print("\n[6/6] Checking environment configuration...")
env_example = backend_dir / ".env.example"
if env_example.exists():
    with open(env_example, 'r') as f:
        content = f.read()
        if "NEON_DATABASE_URL" in content:
            print("βœ“ .env.example contains NEON_DATABASE_URL")
        else:
            print("⚠  .env.example missing NEON_DATABASE_URL")
else:
    print("⚠  .env.example not found")

env_file = backend_dir / ".env"
if env_file.exists():
    print("βœ“ .env file exists")
    with open(env_file, 'r') as f:
        content = f.read()
        if "NEON_DATABASE_URL" in content:
            # Check if it's configured (not default)
            if "your-neon-host" not in content:
                print("βœ“ NEON_DATABASE_URL appears to be configured")
            else:
                print("⚠  NEON_DATABASE_URL needs configuration")
        else:
            print("⚠  .env missing NEON_DATABASE_URL")
else:
    print("⚠  .env file not found - copy from .env.example")

# Summary
print("\n" + "=" * 70)
print("VERIFICATION COMPLETE")
print("=" * 70)
print("\nβœ“ All core components installed successfully!")
print("\nπŸ“‹ Next Steps:")
print("   1. Create Neon database at https://neon.tech")
print("   2. Copy .env.example to .env")
print("   3. Add your NEON_DATABASE_URL to .env")
print("   4. Run: alembic revision --autogenerate -m 'Initial schema'")
print("   5. Run: alembic upgrade head")
print("   6. Run: python scripts/init_db.py")
print("\nπŸ“š See DATABASE_SETUP.md for detailed instructions")
print("=" * 70)